@lumibase/extension-sdk 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +4 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
defineCdcSubscriber: () => defineCdcSubscriber,
|
|
23
24
|
defineHook: () => defineHook,
|
|
24
25
|
defineInterface: () => defineInterface
|
|
25
26
|
});
|
|
@@ -30,8 +31,12 @@ function defineHook(def) {
|
|
|
30
31
|
function defineInterface(def) {
|
|
31
32
|
return def;
|
|
32
33
|
}
|
|
34
|
+
function defineCdcSubscriber(def) {
|
|
35
|
+
return def;
|
|
36
|
+
}
|
|
33
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
38
|
0 && (module.exports = {
|
|
39
|
+
defineCdcSubscriber,
|
|
35
40
|
defineHook,
|
|
36
41
|
defineInterface
|
|
37
42
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -75,5 +75,53 @@ interface InterfaceDefinition<TValue = unknown, TOptions = Record<string, unknow
|
|
|
75
75
|
recommendedDisplays?: string[];
|
|
76
76
|
}
|
|
77
77
|
declare function defineInterface<TValue = unknown, TOptions = Record<string, unknown>>(def: InterfaceDefinition<TValue, TOptions>): InterfaceDefinition<TValue, TOptions>;
|
|
78
|
+
/** One delivered change event; `id` is the idempotency key (at-least-once). */
|
|
79
|
+
interface CdcEvent<TData = Record<string, unknown>> {
|
|
80
|
+
id: string;
|
|
81
|
+
/** `items.<operation>` */
|
|
82
|
+
type: string;
|
|
83
|
+
schemaVersion: number;
|
|
84
|
+
siteId: string;
|
|
85
|
+
collection: string;
|
|
86
|
+
itemId: string;
|
|
87
|
+
operation: 'create' | 'update' | 'delete';
|
|
88
|
+
/** ISO timestamp (Postgres clock). */
|
|
89
|
+
occurredAt: string;
|
|
90
|
+
actor: {
|
|
91
|
+
type: 'user' | 'api_key' | 'agent' | 'system';
|
|
92
|
+
id?: string;
|
|
93
|
+
};
|
|
94
|
+
source: 'api' | 'agent' | 'flow' | 'system';
|
|
95
|
+
changedFields?: string[];
|
|
96
|
+
/** Present only when the subscription uses `payloadMode: 'snapshot'`; pii/phi masked. */
|
|
97
|
+
data?: TData;
|
|
98
|
+
/** Opaque keyset token for this event — resume/ack marker. */
|
|
99
|
+
cursor: string;
|
|
100
|
+
}
|
|
101
|
+
interface CdcSubscriberContext {
|
|
102
|
+
readonly siteId: string;
|
|
103
|
+
readonly config: Record<string, unknown>;
|
|
104
|
+
readonly logger: {
|
|
105
|
+
info(msg: string, meta?: unknown): void;
|
|
106
|
+
warn(msg: string, meta?: unknown): void;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Declares an async change-feed consumer. The host delivers batches
|
|
111
|
+
* at-least-once AFTER the mutation commits (unlike sync `hooks`, this can
|
|
112
|
+
* never block or abort a mutation) and only for collections covered by the
|
|
113
|
+
* manifest's `cdc:subscribe:<collection>` capabilities — the host enforces
|
|
114
|
+
* that filter, not the extension. Handlers MUST be idempotent on `event.id`.
|
|
115
|
+
*/
|
|
116
|
+
interface CdcSubscriberDefinition<TData = Record<string, unknown>> {
|
|
117
|
+
collections: string[];
|
|
118
|
+
operations?: Array<'create' | 'update' | 'delete'>;
|
|
119
|
+
payloadMode?: 'reference' | 'snapshot';
|
|
120
|
+
handler: (input: {
|
|
121
|
+
events: CdcEvent<TData>[];
|
|
122
|
+
ctx: CdcSubscriberContext;
|
|
123
|
+
}) => Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
declare function defineCdcSubscriber<TData = Record<string, unknown>>(def: CdcSubscriberDefinition<TData>): CdcSubscriberDefinition<TData>;
|
|
78
126
|
|
|
79
|
-
export { type ExtensionManifest, type ExtensionType, type HookContext, type HookDefinition, type InterfaceComponent, type InterfaceDefinition, type InterfaceGroup, type InterfaceOption, type InterfaceOptionType, type InterfaceProps, defineHook, defineInterface };
|
|
127
|
+
export { type CdcEvent, type CdcSubscriberContext, type CdcSubscriberDefinition, type ExtensionManifest, type ExtensionType, type HookContext, type HookDefinition, type InterfaceComponent, type InterfaceDefinition, type InterfaceGroup, type InterfaceOption, type InterfaceOptionType, type InterfaceProps, defineCdcSubscriber, defineHook, defineInterface };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,5 +75,53 @@ interface InterfaceDefinition<TValue = unknown, TOptions = Record<string, unknow
|
|
|
75
75
|
recommendedDisplays?: string[];
|
|
76
76
|
}
|
|
77
77
|
declare function defineInterface<TValue = unknown, TOptions = Record<string, unknown>>(def: InterfaceDefinition<TValue, TOptions>): InterfaceDefinition<TValue, TOptions>;
|
|
78
|
+
/** One delivered change event; `id` is the idempotency key (at-least-once). */
|
|
79
|
+
interface CdcEvent<TData = Record<string, unknown>> {
|
|
80
|
+
id: string;
|
|
81
|
+
/** `items.<operation>` */
|
|
82
|
+
type: string;
|
|
83
|
+
schemaVersion: number;
|
|
84
|
+
siteId: string;
|
|
85
|
+
collection: string;
|
|
86
|
+
itemId: string;
|
|
87
|
+
operation: 'create' | 'update' | 'delete';
|
|
88
|
+
/** ISO timestamp (Postgres clock). */
|
|
89
|
+
occurredAt: string;
|
|
90
|
+
actor: {
|
|
91
|
+
type: 'user' | 'api_key' | 'agent' | 'system';
|
|
92
|
+
id?: string;
|
|
93
|
+
};
|
|
94
|
+
source: 'api' | 'agent' | 'flow' | 'system';
|
|
95
|
+
changedFields?: string[];
|
|
96
|
+
/** Present only when the subscription uses `payloadMode: 'snapshot'`; pii/phi masked. */
|
|
97
|
+
data?: TData;
|
|
98
|
+
/** Opaque keyset token for this event — resume/ack marker. */
|
|
99
|
+
cursor: string;
|
|
100
|
+
}
|
|
101
|
+
interface CdcSubscriberContext {
|
|
102
|
+
readonly siteId: string;
|
|
103
|
+
readonly config: Record<string, unknown>;
|
|
104
|
+
readonly logger: {
|
|
105
|
+
info(msg: string, meta?: unknown): void;
|
|
106
|
+
warn(msg: string, meta?: unknown): void;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Declares an async change-feed consumer. The host delivers batches
|
|
111
|
+
* at-least-once AFTER the mutation commits (unlike sync `hooks`, this can
|
|
112
|
+
* never block or abort a mutation) and only for collections covered by the
|
|
113
|
+
* manifest's `cdc:subscribe:<collection>` capabilities — the host enforces
|
|
114
|
+
* that filter, not the extension. Handlers MUST be idempotent on `event.id`.
|
|
115
|
+
*/
|
|
116
|
+
interface CdcSubscriberDefinition<TData = Record<string, unknown>> {
|
|
117
|
+
collections: string[];
|
|
118
|
+
operations?: Array<'create' | 'update' | 'delete'>;
|
|
119
|
+
payloadMode?: 'reference' | 'snapshot';
|
|
120
|
+
handler: (input: {
|
|
121
|
+
events: CdcEvent<TData>[];
|
|
122
|
+
ctx: CdcSubscriberContext;
|
|
123
|
+
}) => Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
declare function defineCdcSubscriber<TData = Record<string, unknown>>(def: CdcSubscriberDefinition<TData>): CdcSubscriberDefinition<TData>;
|
|
78
126
|
|
|
79
|
-
export { type ExtensionManifest, type ExtensionType, type HookContext, type HookDefinition, type InterfaceComponent, type InterfaceDefinition, type InterfaceGroup, type InterfaceOption, type InterfaceOptionType, type InterfaceProps, defineHook, defineInterface };
|
|
127
|
+
export { type CdcEvent, type CdcSubscriberContext, type CdcSubscriberDefinition, type ExtensionManifest, type ExtensionType, type HookContext, type HookDefinition, type InterfaceComponent, type InterfaceDefinition, type InterfaceGroup, type InterfaceOption, type InterfaceOptionType, type InterfaceProps, defineCdcSubscriber, defineHook, defineInterface };
|
package/dist/index.js
CHANGED