@flatfile/listener
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,4 +0,4 @@ | ||
module.exports = { | ||
export default { | ||
root: true, | ||
extends: ['@flatfile/eslint-config-platform-sdk'], | ||
} |
# @flatfile/listener | ||
## 0.1.1 | ||
### Patch Changes | ||
- 356c35d: Minor CI improvements and backwards compatible rename of Client to FlatfileListener | ||
## 0.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -162,3 +162,3 @@ import { FetchAPI, DefaultApi, Event } from '@flatfile/api'; | ||
/** | ||
* The Client | ||
* The Flatfile Listener | ||
* | ||
@@ -192,3 +192,3 @@ * The Flatfile PubSub Client is just a simple event subscriber. It can | ||
declare class Client extends EventHandler { | ||
declare class FlatfileListener extends EventHandler { | ||
/** | ||
@@ -200,3 +200,3 @@ * Subscribe to events only within a certain namespace. | ||
*/ | ||
namespace(namespace: string | string[], cb?: SubFn): Client; | ||
namespace(namespace: string | string[], cb?: SubFn): FlatfileListener; | ||
/** | ||
@@ -208,5 +208,3 @@ * Filter by namespace | ||
*/ | ||
filter(filter: EventFilter, cb?: SubFn): Client; | ||
setupFunctions: Array<(...args: any[]) => void>; | ||
beforeMount(cb: SubFn): void; | ||
filter(filter: EventFilter, cb?: SubFn): FlatfileListener; | ||
/** | ||
@@ -217,3 +215,3 @@ * Start subscribing to events | ||
*/ | ||
static create(cb: SubFn): Client; | ||
static create(cb: SubFn): FlatfileListener; | ||
/** | ||
@@ -224,3 +222,3 @@ * Mount this client using an acceptable Event Driver | ||
} | ||
type SubFn = (client: Client) => void; | ||
type SubFn = (client: FlatfileListener) => void; | ||
@@ -270,2 +268,8 @@ declare class Browser extends EventDriver { | ||
export { Arrayable, AuthenticatedClient, Browser, Client, EventCallback, EventFilter, EventHandler, FlatfileEvent, FlatfileVirtualMachine, PollingEventDriver }; | ||
/** | ||
* Backwards compatibility | ||
*/ | ||
declare class Client extends FlatfileListener { | ||
} | ||
export { Arrayable, AuthenticatedClient, Browser, Client, EventCallback, EventFilter, EventHandler, FlatfileEvent, FlatfileListener, FlatfileVirtualMachine, PollingEventDriver }; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
@@ -10,2 +11,6 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
@@ -27,6 +32,7 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// ../../node_modules/ansi-colors/symbols.js | ||
var require_symbols = __commonJS({ | ||
"../../node_modules/ansi-colors/symbols.js"(exports, module) { | ||
"../../node_modules/ansi-colors/symbols.js"(exports, module2) { | ||
"use strict"; | ||
@@ -92,6 +98,6 @@ var isHyper = typeof process !== "undefined" && process.env.TERM_PROGRAM === "Hyper"; | ||
}); | ||
module.exports = isWindows && !isHyper ? windows : other; | ||
Reflect.defineProperty(module.exports, "common", { enumerable: false, value: common }); | ||
Reflect.defineProperty(module.exports, "windows", { enumerable: false, value: windows }); | ||
Reflect.defineProperty(module.exports, "other", { enumerable: false, value: other }); | ||
module2.exports = isWindows && !isHyper ? windows : other; | ||
Reflect.defineProperty(module2.exports, "common", { enumerable: false, value: common }); | ||
Reflect.defineProperty(module2.exports, "windows", { enumerable: false, value: windows }); | ||
Reflect.defineProperty(module2.exports, "other", { enumerable: false, value: other }); | ||
} | ||
@@ -102,3 +108,3 @@ }); | ||
var require_ansi_colors = __commonJS({ | ||
"../../node_modules/ansi-colors/index.js"(exports, module) { | ||
"../../node_modules/ansi-colors/index.js"(exports, module2) { | ||
"use strict"; | ||
@@ -263,10 +269,24 @@ var isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val); | ||
}; | ||
module.exports = create(); | ||
module.exports.create = create; | ||
module2.exports = create(); | ||
module2.exports.create = create; | ||
} | ||
}); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
AuthenticatedClient: () => AuthenticatedClient, | ||
Browser: () => Browser, | ||
Client: () => Client, | ||
EventHandler: () => EventHandler, | ||
FlatfileEvent: () => FlatfileEvent, | ||
FlatfileListener: () => FlatfileListener, | ||
FlatfileVirtualMachine: () => FlatfileVirtualMachine, | ||
PollingEventDriver: () => PollingEventDriver | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/events/authenticated.client.ts | ||
import { Configuration, DefaultApi } from "@flatfile/api"; | ||
import fetch from "node-fetch"; | ||
var import_api = require("@flatfile/api"); | ||
var import_node_fetch = __toESM(require("node-fetch")); | ||
var FLATFILE_API_URL = process.env.AGENT_INTERNAL_URL || "http://localhost:3000"; | ||
@@ -284,5 +304,5 @@ var AuthenticatedClient = class { | ||
const apiUrl = this._apiUrl; | ||
const ClientConfig = new Configuration({ | ||
const ClientConfig = new import_api.Configuration({ | ||
basePath: `${apiUrl}/v1`, | ||
fetchApi: fetch, | ||
fetchApi: import_node_fetch.default, | ||
accessToken, | ||
@@ -294,3 +314,3 @@ headers: { | ||
}); | ||
this._api = new DefaultApi(ClientConfig); | ||
this._api = new import_api.DefaultApi(ClientConfig); | ||
return this._api; | ||
@@ -307,3 +327,3 @@ } | ||
const fetchUrl = this._apiUrl + "/" + url; | ||
this._fetchApi = fetch(fetchUrl, { | ||
this._fetchApi = (0, import_node_fetch.default)(fetchUrl, { | ||
headers | ||
@@ -384,3 +404,3 @@ }).then((resp) => resp.json()).then((resp) => resp.data); | ||
this.target = src.target || ""; | ||
this.action = src.context.actionName || ""; | ||
this.action = src.context?.actionName || ""; | ||
} | ||
@@ -527,3 +547,3 @@ /** | ||
// src/events/glob.match.ts | ||
import flat from "flat"; | ||
var import_flat = __toESM(require("flat")); | ||
function glob(val, filter) { | ||
@@ -541,4 +561,4 @@ if (!val || typeof val !== "string") { | ||
let denied = false; | ||
const filter = flat(cleanFilter, { safe: true }); | ||
const flattened = flat(object, { safe: true }); | ||
const filter = (0, import_flat.default)(cleanFilter, { safe: true }); | ||
const flattened = (0, import_flat.default)(object, { safe: true }); | ||
for (const keyPattern in filter) { | ||
@@ -694,8 +714,4 @@ const keys = filterKeys(flattened, keyPattern); | ||
// src/Client.ts | ||
var Client = class extends EventHandler { | ||
constructor() { | ||
super(...arguments); | ||
this.setupFunctions = []; | ||
} | ||
// src/flatfile.listener.ts | ||
var FlatfileListener = class extends EventHandler { | ||
/** | ||
@@ -717,3 +733,3 @@ * Subscribe to events only within a certain namespace. | ||
filter(filter, cb) { | ||
const client = new Client(filter); | ||
const client = new FlatfileListener(filter); | ||
this.addNode(client); | ||
@@ -723,5 +739,2 @@ cb?.(client); | ||
} | ||
beforeMount(cb) { | ||
this.setupFunctions.push(cb); | ||
} | ||
/** | ||
@@ -733,4 +746,4 @@ * Start subscribing to events | ||
static create(cb) { | ||
const client = new Client(); | ||
client.beforeMount(() => cb(client)); | ||
const client = new FlatfileListener(); | ||
cb(client); | ||
return client; | ||
@@ -742,3 +755,2 @@ } | ||
mount(driver) { | ||
this.setupFunctions.forEach((f) => f()); | ||
driver.mountEventHandler(this); | ||
@@ -803,3 +815,3 @@ return this; | ||
// src/event-drivers/Polling.ts | ||
var import_ansi_colors = __toESM(require_ansi_colors(), 1); | ||
var import_ansi_colors = __toESM(require_ansi_colors()); | ||
var events = /* @__PURE__ */ new Map(); | ||
@@ -878,3 +890,8 @@ var PollingEventDriver = class extends EventDriver { | ||
}; | ||
export { | ||
// src/index.ts | ||
var Client = class extends FlatfileListener { | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
AuthenticatedClient, | ||
@@ -885,4 +902,5 @@ Browser, | ||
FlatfileEvent, | ||
FlatfileListener, | ||
FlatfileVirtualMachine, | ||
PollingEventDriver | ||
}; | ||
}); |
{ | ||
"name": "@flatfile/listener", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A PubSub Listener for configuring and using Flatfile", | ||
@@ -8,3 +8,2 @@ "main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"type": "module", | ||
"scripts": { | ||
@@ -14,3 +13,4 @@ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", | ||
"dev": "tsup src/index.ts --format esm,cjs --dts --watch", | ||
"poll": "tsup src/dev.ts --format esm,cjs --watch --dts --onSuccess \"node dist/dev.js\"" | ||
"poll": "tsup src/dev.ts --format esm,cjs --watch --dts --onSuccess \"node dist/dev.js\"", | ||
"test": "jest --passWithNoTests" | ||
}, | ||
@@ -17,0 +17,0 @@ "license": "MIT", |
@@ -40,3 +40,3 @@ import { AuthenticatedClient } from './authenticated.client' | ||
this.target = src.target || '' | ||
this.action = src.context.actionName || '' | ||
this.action = src.context?.actionName || '' | ||
} | ||
@@ -43,0 +43,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { Client, FlatfileVirtualMachine } from '../' | ||
import { FlatfileListener, FlatfileVirtualMachine } from '../' | ||
const example = Client.create((client) => { | ||
const example = FlatfileListener.create((client) => { | ||
/** | ||
@@ -5,0 +5,0 @@ * This is a basic hook on events with no sugar on top |
@@ -1,3 +0,9 @@ | ||
export * from './Client' | ||
import { FlatfileListener } from './flatfile.listener' | ||
export * from './flatfile.listener' | ||
export * from './event-drivers' | ||
export * from './events' | ||
/** | ||
* Backwards compatibility | ||
*/ | ||
export class Client extends FlatfileListener {} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100215
3108
No