@notionhq/workers 0.0.86 → 0.2.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/ajv-formats.d.js +0 -0
- package/dist/capabilities/automation.js +2 -2
- package/dist/capabilities/sync.d.ts +73 -16
- package/dist/capabilities/sync.d.ts.map +1 -1
- package/dist/capabilities/sync.js +19 -10
- package/dist/capabilities/tool.d.ts.map +1 -1
- package/dist/capabilities/tool.js +18 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/pacer.d.ts +24 -0
- package/dist/pacer.d.ts.map +1 -0
- package/dist/pacer.js +14 -0
- package/dist/pacer.test.d.ts +2 -0
- package/dist/pacer.test.d.ts.map +1 -0
- package/dist/pacer_internal.d.ts +6 -0
- package/dist/pacer_internal.d.ts.map +1 -0
- package/dist/pacer_internal.js +32 -0
- package/dist/schema.d.ts +3 -10
- package/dist/schema.d.ts.map +1 -1
- package/dist/types.d.ts +5 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +138 -5
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +73 -7
- package/dist/worker.test.d.ts +2 -0
- package/dist/worker.test.d.ts.map +1 -0
- package/package.json +7 -2
- package/src/ajv-formats.d.ts +7 -0
- package/src/capabilities/automation.test.ts +2 -2
- package/src/capabilities/automation.ts +2 -2
- package/src/capabilities/sync.test.ts +89 -32
- package/src/capabilities/sync.ts +52 -25
- package/src/capabilities/tool.test.ts +47 -3
- package/src/capabilities/tool.ts +12 -4
- package/src/index.ts +9 -0
- package/src/pacer.test.ts +110 -0
- package/src/pacer.ts +25 -0
- package/src/pacer_internal.ts +60 -0
- package/src/schema.ts +3 -10
- package/src/types.ts +4 -2
- package/src/worker.test.ts +167 -0
- package/src/worker.ts +205 -7
|
File without changes
|
|
@@ -17,7 +17,7 @@ function createAutomationCapability(key, config) {
|
|
|
17
17
|
} else {
|
|
18
18
|
process.stdout.write(
|
|
19
19
|
`
|
|
20
|
-
<
|
|
20
|
+
<__notion_output__>${JSON.stringify({ _tag: "success", value: { status: "success" } })}</__notion_output__>
|
|
21
21
|
`
|
|
22
22
|
);
|
|
23
23
|
}
|
|
@@ -26,7 +26,7 @@ function createAutomationCapability(key, config) {
|
|
|
26
26
|
if (!options?.concreteOutput) {
|
|
27
27
|
process.stdout.write(
|
|
28
28
|
`
|
|
29
|
-
<
|
|
29
|
+
<__notion_output__>${JSON.stringify({ _tag: "error", error: { name: error.name, message: error.message, trace: error.stack } })}</__notion_output__>
|
|
30
30
|
`
|
|
31
31
|
);
|
|
32
32
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type PacerEntry } from "../pacer_internal.js";
|
|
1
2
|
import type { PropertyConfiguration, PropertySchema, Schema } from "../schema.js";
|
|
2
3
|
import type { HandlerOptions, Icon, PeopleValue, PlaceValue, RelationValue, Schedule, SyncSchedule, TextValue } from "../types.js";
|
|
4
|
+
import type { DatabaseHandle } from "../worker.js";
|
|
3
5
|
import type { CapabilityContext } from "./context.js";
|
|
4
6
|
/**
|
|
5
7
|
* Maps a property configuration to its corresponding value type.
|
|
@@ -25,9 +27,13 @@ export type SyncChangeUpsert<PK extends string, S extends PropertySchema<PK>> =
|
|
|
25
27
|
type: "upsert";
|
|
26
28
|
/**
|
|
27
29
|
* A unique identifier for this record, used to match against existing pages.
|
|
28
|
-
* This value will be stored in the property specified by `primaryKeyProperty`.
|
|
29
30
|
*/
|
|
30
31
|
key: string;
|
|
32
|
+
/**
|
|
33
|
+
* The key of the database to write to. If omitted, defaults to
|
|
34
|
+
* the database associated with the sync capability.
|
|
35
|
+
*/
|
|
36
|
+
targetDatabaseKey?: string;
|
|
31
37
|
/**
|
|
32
38
|
* The property values for this record.
|
|
33
39
|
* Keys must match the property names defined in the schema.
|
|
@@ -36,6 +42,13 @@ export type SyncChangeUpsert<PK extends string, S extends PropertySchema<PK>> =
|
|
|
36
42
|
properties: {
|
|
37
43
|
[Property in keyof S]: PropertyValueType<S[Property]>;
|
|
38
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* When this record was last updated in the upstream system.
|
|
47
|
+
* ISO 8601 string (e.g. `"2026-03-19T12:00:00Z"`).
|
|
48
|
+
* Used for conflict resolution when multiple syncs write to the same database.
|
|
49
|
+
* Recommended, but optional.
|
|
50
|
+
*/
|
|
51
|
+
upstreamUpdatedAt?: string;
|
|
39
52
|
/**
|
|
40
53
|
* Optional icon to use as the icon for this row's page.
|
|
41
54
|
* Use the `Builder.emojiIcon()`, `Builder.notionIcon()`, or `Builder.imageIcon()` helpers.
|
|
@@ -58,9 +71,13 @@ export type SyncChangeDelete = {
|
|
|
58
71
|
type: "delete";
|
|
59
72
|
/**
|
|
60
73
|
* The unique identifier of the record to delete.
|
|
61
|
-
* Must match the `key` of a previously upserted record.
|
|
62
74
|
*/
|
|
63
75
|
key: string;
|
|
76
|
+
/**
|
|
77
|
+
* The key of the database to delete from. If omitted, defaults to
|
|
78
|
+
* the database associated with the sync capability.
|
|
79
|
+
*/
|
|
80
|
+
targetDatabaseKey?: string;
|
|
64
81
|
};
|
|
65
82
|
/**
|
|
66
83
|
* A change to be applied to the synced database.
|
|
@@ -91,20 +108,13 @@ export type SyncExecutionResult<PK extends string, State = unknown> = {
|
|
|
91
108
|
nextState?: State;
|
|
92
109
|
};
|
|
93
110
|
/**
|
|
94
|
-
*
|
|
95
|
-
* source and a third-party source.
|
|
111
|
+
* Configuration for a sync capability that syncs data to a database.
|
|
96
112
|
*/
|
|
97
113
|
export type SyncConfiguration<PK extends string, S extends Schema<PK>, State = unknown> = {
|
|
98
114
|
/**
|
|
99
|
-
* The
|
|
100
|
-
* third-party data. This is used to match existing pages to
|
|
101
|
-
* records in the third-party service. Must be a property defined in the schema.
|
|
102
|
-
*/
|
|
103
|
-
primaryKeyProperty: PK;
|
|
104
|
-
/**
|
|
105
|
-
* The schema defining the structure of properties in the collection.
|
|
115
|
+
* The database to sync data into.
|
|
106
116
|
*/
|
|
107
|
-
|
|
117
|
+
database: DatabaseHandle<PK, S>;
|
|
108
118
|
/**
|
|
109
119
|
* How the sync handles data lifecycle:
|
|
110
120
|
* - "replace": Each sync returns the complete dataset. After hasMore:false,
|
|
@@ -119,6 +129,7 @@ export type SyncConfiguration<PK extends string, S extends Schema<PK>, State = u
|
|
|
119
129
|
/**
|
|
120
130
|
* How often the sync should run.
|
|
121
131
|
* - "continuous": Run as frequently as the system allows
|
|
132
|
+
* - "manual": Only run when explicitly triggered
|
|
122
133
|
* - Interval string: Run at specified intervals, e.g. "1h", "30m", "1d"
|
|
123
134
|
*
|
|
124
135
|
* Minimum interval: 1 minute ("1m")
|
|
@@ -153,9 +164,11 @@ type RuntimeContext<UserContext = unknown> = {
|
|
|
153
164
|
state?: UserContext;
|
|
154
165
|
/** Legacy field for user-defined/-controlled state. */
|
|
155
166
|
userContext?: UserContext;
|
|
167
|
+
/** Pacer state from the server for rate limiting. */
|
|
168
|
+
pacers?: Record<string, PacerEntry>;
|
|
156
169
|
};
|
|
157
170
|
/**
|
|
158
|
-
* Creates a special handler for syncing third-party data to a
|
|
171
|
+
* Creates a special handler for syncing third-party data to a database.
|
|
159
172
|
*
|
|
160
173
|
* @param syncConfiguration - The configuration for the sync.
|
|
161
174
|
* @returns A handler function that executes the sync function, and passes data
|
|
@@ -165,15 +178,59 @@ export declare function createSyncCapability<PK extends string, S extends Schema
|
|
|
165
178
|
_tag: "sync";
|
|
166
179
|
key: string;
|
|
167
180
|
config: {
|
|
181
|
+
databaseKey: string;
|
|
168
182
|
primaryKeyProperty: PK;
|
|
169
|
-
schema: S;
|
|
170
183
|
mode: SyncMode | undefined;
|
|
171
|
-
schedule: SyncSchedule;
|
|
184
|
+
schedule: SyncSchedule | undefined;
|
|
172
185
|
};
|
|
173
186
|
handler(runtimeContext?: RuntimeContext<Context>, options?: HandlerOptions): Promise<{
|
|
174
|
-
changes:
|
|
187
|
+
changes: ({
|
|
188
|
+
targetDatabaseKey: string;
|
|
189
|
+
/**
|
|
190
|
+
* The type of change. Use `"delete"` to remove a record.
|
|
191
|
+
*/
|
|
192
|
+
type: "delete";
|
|
193
|
+
/**
|
|
194
|
+
* The unique identifier of the record to delete.
|
|
195
|
+
*/
|
|
196
|
+
key: string;
|
|
197
|
+
} | {
|
|
198
|
+
targetDatabaseKey: string;
|
|
199
|
+
/**
|
|
200
|
+
* The type of change. Use `"upsert"` to create or update a record.
|
|
201
|
+
*/
|
|
202
|
+
type: "upsert";
|
|
203
|
+
/**
|
|
204
|
+
* A unique identifier for this record, used to match against existing pages.
|
|
205
|
+
*/
|
|
206
|
+
key: string;
|
|
207
|
+
/**
|
|
208
|
+
* The property values for this record.
|
|
209
|
+
* Keys must match the property names defined in the schema.
|
|
210
|
+
* Use the Builder helpers (e.g., `Builder.title()`, `Builder.richText()`) to create values.
|
|
211
|
+
*/
|
|
212
|
+
properties: PropertySchema<PK> extends infer T extends PropertySchema<PK_1> ? { [Property in keyof T]: PropertyValueType<T[Property]>; } : never;
|
|
213
|
+
/**
|
|
214
|
+
* When this record was last updated in the upstream system.
|
|
215
|
+
* ISO 8601 string (e.g. `"2026-03-19T12:00:00Z"`).
|
|
216
|
+
* Used for conflict resolution when multiple syncs write to the same database.
|
|
217
|
+
* Recommended, but optional.
|
|
218
|
+
*/
|
|
219
|
+
upstreamUpdatedAt?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Optional icon to use as the icon for this row's page.
|
|
222
|
+
* Use the `Builder.emojiIcon()`, `Builder.notionIcon()`, or `Builder.imageIcon()` helpers.
|
|
223
|
+
*/
|
|
224
|
+
icon?: Icon;
|
|
225
|
+
/**
|
|
226
|
+
* Optional markdown content to add to the page body.
|
|
227
|
+
* This will be converted to Notion blocks and added as page content.
|
|
228
|
+
*/
|
|
229
|
+
pageContentMarkdown?: string;
|
|
230
|
+
})[];
|
|
175
231
|
hasMore: boolean;
|
|
176
232
|
nextUserContext: Context | undefined;
|
|
233
|
+
nextPacerStates: Record<string, PacerEntry>;
|
|
177
234
|
}>;
|
|
178
235
|
};
|
|
179
236
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/capabilities/sync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACX,cAAc,EACd,IAAI,EACJ,WAAW,EACX,UAAU,EACV,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,SAAS,EAET,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD;;GAEG;AACH,KAAK,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,IAAI,CAAC,SAAS;IACnE,IAAI,EAAE,QAAQ,CAAC;CACf,GACE,WAAW,GACX,CAAC,SAAS;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B,UAAU,GACV,CAAC,SAAS;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B,aAAa,GACb,SAAS,CAAC;AAEf;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,aAAa,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC3B,EAAE,SAAS,MAAM,EACjB,CAAC,SAAS,cAAc,CAAC,EAAE,CAAC,IACzB;IACH;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/capabilities/sync.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,UAAU,EAEf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACX,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACX,cAAc,EACd,IAAI,EACJ,WAAW,EACX,UAAU,EACV,aAAa,EACb,QAAQ,EAC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AAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,SAAS,MAAM,EACjB,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,EACpB,OAAO,GAAG,OAAO,EAChB,GAAG,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC;;;;;;;;;6BAa/C,cAAc,CAAC,OAAO,CAAC,YAC9B,cAAc;;;YAnJ1B;;eAEG;kBACG,QAAQ;YACd;;eAEG;iBACE,MAAM;;;YApDX;;eAEG;kBACG,QAAQ;YACd;;eAEG;iBACE,MAAM;YAMX;;;;eAIG;6FAED,QAAQ;YAEV;;;;;eAKG;gCACiB,MAAM;YAC1B;;;eAGG;mBACI,IAAI;YACX;;;eAGG;kCACmB,MAAM;;;;;;EA2M5B"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { ExecutionError, unreachable } from "../error.js";
|
|
2
|
+
import {
|
|
3
|
+
getPacerState,
|
|
4
|
+
setPacerState
|
|
5
|
+
} from "../pacer_internal.js";
|
|
2
6
|
import { createCapabilityContext } from "./context.js";
|
|
3
7
|
function createSyncCapability(key, syncConfiguration) {
|
|
4
8
|
return {
|
|
5
9
|
_tag: "sync",
|
|
6
10
|
key,
|
|
7
11
|
config: {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
databaseKey: syncConfiguration.database.key,
|
|
13
|
+
primaryKeyProperty: syncConfiguration.database.config.primaryKeyProperty,
|
|
10
14
|
mode: syncConfiguration.mode,
|
|
11
|
-
schedule: parseSchedule(syncConfiguration.schedule)
|
|
15
|
+
schedule: syncConfiguration.schedule ? parseSchedule(syncConfiguration.schedule) : void 0
|
|
12
16
|
},
|
|
13
17
|
async handler(runtimeContext, options) {
|
|
14
18
|
const capabilityContext = createCapabilityContext();
|
|
15
19
|
const state = runtimeContext?.state ?? runtimeContext?.userContext;
|
|
20
|
+
setPacerState({ pacers: runtimeContext?.pacers ?? {} });
|
|
16
21
|
let executionResult;
|
|
17
22
|
try {
|
|
18
23
|
executionResult = await syncConfiguration.execute(
|
|
@@ -24,23 +29,28 @@ function createSyncCapability(key, syncConfiguration) {
|
|
|
24
29
|
if (!options?.concreteOutput) {
|
|
25
30
|
process.stdout.write(
|
|
26
31
|
`
|
|
27
|
-
<
|
|
32
|
+
<__notion_output__>${JSON.stringify({ _tag: "error", error: { name: error.name, message: error.message } })}</__notion_output__>
|
|
28
33
|
`
|
|
29
34
|
);
|
|
30
35
|
}
|
|
31
36
|
throw error;
|
|
32
37
|
}
|
|
38
|
+
const changes = executionResult.changes.map((change) => ({
|
|
39
|
+
...change,
|
|
40
|
+
targetDatabaseKey: change.targetDatabaseKey ?? syncConfiguration.database.key
|
|
41
|
+
}));
|
|
33
42
|
const result = {
|
|
34
|
-
changes
|
|
43
|
+
changes,
|
|
35
44
|
hasMore: executionResult.hasMore,
|
|
36
|
-
nextUserContext: executionResult.nextState
|
|
45
|
+
nextUserContext: executionResult.nextState,
|
|
46
|
+
nextPacerStates: getPacerState().pacers
|
|
37
47
|
};
|
|
38
48
|
if (options?.concreteOutput) {
|
|
39
49
|
return result;
|
|
40
50
|
} else {
|
|
41
51
|
process.stdout.write(
|
|
42
52
|
`
|
|
43
|
-
<
|
|
53
|
+
<__notion_output__>${JSON.stringify({ _tag: "success", value: result })}</__notion_output__>
|
|
44
54
|
`
|
|
45
55
|
);
|
|
46
56
|
}
|
|
@@ -53,13 +63,12 @@ const MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
|
53
63
|
const MS_PER_DAY = 24 * MS_PER_HOUR;
|
|
54
64
|
const MIN_INTERVAL_MS = MS_PER_MINUTE;
|
|
55
65
|
const MAX_INTERVAL_MS = 7 * MS_PER_DAY;
|
|
56
|
-
const DEFAULT_INTERVAL_MS = 30 * MS_PER_MINUTE;
|
|
57
66
|
function parseSchedule(schedule) {
|
|
58
67
|
if (schedule === "continuous") {
|
|
59
68
|
return { type: "continuous" };
|
|
60
69
|
}
|
|
61
|
-
if (
|
|
62
|
-
return { type: "
|
|
70
|
+
if (schedule === "manual") {
|
|
71
|
+
return { type: "manual" };
|
|
63
72
|
}
|
|
64
73
|
const match = schedule.match(/^(\d+)(m|h|d)$/);
|
|
65
74
|
if (!match || !match[1] || !match[2]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/capabilities/tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/capabilities/tool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAiEtD,MAAM,WAAW,iBAAiB,CACjC,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,SAAS,GAAG,SAAS;IAE/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACzB,YAAY,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAClE;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;IAK3B,MAAM;;;;;CAON;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;IAK3B,MAAM;;;;;CAON;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;IAK3B,MAAM;;;;;CAON;AAED,MAAM,MAAM,cAAc,CACzB,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,SAAS,GAAG,SAAS,IAC5B,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,SAAS,GAAG,SAAS,EAC9B,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;gBAiBf,SAAS,WAAW,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;gBAC/C,SAAS,GAAG,OAAO,CAC9C;YACA,IAAI,EAAE,SAAS,CAAC;YAChB,KAAK,EAAE,CAAC,CAAC;SACR,GACD;YACA,IAAI,EAAE,OAAO,CAAC;YACd,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;aAAE,CAAC;SACnE,CACH;;EAoHD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Ajv } from "ajv";
|
|
2
|
+
import addFormats from "ajv-formats";
|
|
2
3
|
import { getSchema } from "../schema-builder.js";
|
|
3
4
|
import { createCapabilityContext } from "./context.js";
|
|
4
5
|
function validateRequiredProperties(schema, path = "") {
|
|
@@ -88,6 +89,7 @@ function createToolCapability(key, config) {
|
|
|
88
89
|
validateRequiredProperties(outputSchema);
|
|
89
90
|
}
|
|
90
91
|
const ajv = new Ajv();
|
|
92
|
+
addFormats(ajv);
|
|
91
93
|
const validateInput = ajv.compile(inputSchema);
|
|
92
94
|
const validateOutput = outputSchema ? ajv.compile(outputSchema) : null;
|
|
93
95
|
async function handler(input, options) {
|
|
@@ -107,9 +109,11 @@ function createToolCapability(key, config) {
|
|
|
107
109
|
_tag: "error",
|
|
108
110
|
error: { name: error.name, message: error.message, trace: error.stack }
|
|
109
111
|
};
|
|
110
|
-
process.stdout.write(
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
process.stdout.write(
|
|
113
|
+
`
|
|
114
|
+
<__notion_output__>${JSON.stringify(result)}</__notion_output__>
|
|
115
|
+
`
|
|
116
|
+
);
|
|
113
117
|
return result;
|
|
114
118
|
}
|
|
115
119
|
try {
|
|
@@ -130,9 +134,11 @@ function createToolCapability(key, config) {
|
|
|
130
134
|
trace: error.stack
|
|
131
135
|
}
|
|
132
136
|
};
|
|
133
|
-
process.stdout.write(
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
process.stdout.write(
|
|
138
|
+
`
|
|
139
|
+
<__notion_output__>${JSON.stringify(result2)}</__notion_output__>
|
|
140
|
+
`
|
|
141
|
+
);
|
|
136
142
|
return result2;
|
|
137
143
|
}
|
|
138
144
|
if (options?.concreteOutput) {
|
|
@@ -140,7 +146,7 @@ function createToolCapability(key, config) {
|
|
|
140
146
|
}
|
|
141
147
|
process.stdout.write(
|
|
142
148
|
`
|
|
143
|
-
<
|
|
149
|
+
<__notion_output__>${JSON.stringify({ _tag: "success", value: result })}</__notion_output__>
|
|
144
150
|
`
|
|
145
151
|
);
|
|
146
152
|
return {
|
|
@@ -158,9 +164,11 @@ function createToolCapability(key, config) {
|
|
|
158
164
|
_tag: "error",
|
|
159
165
|
error: { name: error.name, message: error.message, trace: error.stack }
|
|
160
166
|
};
|
|
161
|
-
process.stdout.write(
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
process.stdout.write(
|
|
168
|
+
`
|
|
169
|
+
<__notion_output__>${JSON.stringify(result)}</__notion_output__>
|
|
170
|
+
`
|
|
171
|
+
);
|
|
164
172
|
return result;
|
|
165
173
|
}
|
|
166
174
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export type { AnyJSONSchema, JSONSchema } from "./json-schema.js";
|
|
|
8
8
|
export type { Infer, SchemaBuilder } from "./schema-builder.js";
|
|
9
9
|
export { getSchema, j } from "./schema-builder.js";
|
|
10
10
|
export type { Icon, ImageIcon, NoticonColor, NoticonName, PlaceValue, Schedule, } from "./types.js";
|
|
11
|
+
export type { DatabaseConfig, DatabaseHandle, ManagedDatabaseConfig, PacerConfig, PacerDeclaration, PacerHandle, WorkerManifest, } from "./worker.js";
|
|
11
12
|
export { Worker } from "./worker.js";
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvE,YAAY,EACX,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACX,+BAA+B,EAC/B,eAAe,EACf,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,GACR,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChF,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,GACR,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvE,YAAY,EACX,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACX,+BAA+B,EAC/B,eAAe,EACf,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,GACR,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChF,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,GACR,MAAM,YAAY,CAAC;AACpB,YAAY,EACX,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/pacer.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pacer module for rate limiting API requests.
|
|
3
|
+
*
|
|
4
|
+
* The preferred API is the handle returned by `worker.pacer()`:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const apiPacer = worker.pacer("myApi", { allowedRequests: 10, intervalMs: 1000 });
|
|
8
|
+
* await apiPacer.wait();
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { pacerWait } from "./pacer_internal.js";
|
|
14
|
+
export declare const Pacer: {
|
|
15
|
+
/**
|
|
16
|
+
* Wait until a request can proceed under the named pacer's rate limit.
|
|
17
|
+
*
|
|
18
|
+
* Prefer using the handle-based API instead: `await myPacer.wait()`.
|
|
19
|
+
*
|
|
20
|
+
* @param key - The pacer key, matching the key used in `worker.pacer()`.
|
|
21
|
+
*/
|
|
22
|
+
wait: typeof pacerWait;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=pacer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pacer.d.ts","sourceRoot":"","sources":["../src/pacer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,eAAO,MAAM,KAAK;IACjB;;;;;;OAMG;;CAEH,CAAC"}
|
package/dist/pacer.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { pacerWait } from "./pacer_internal.js";
|
|
2
|
+
const Pacer = {
|
|
3
|
+
/**
|
|
4
|
+
* Wait until a request can proceed under the named pacer's rate limit.
|
|
5
|
+
*
|
|
6
|
+
* Prefer using the handle-based API instead: `await myPacer.wait()`.
|
|
7
|
+
*
|
|
8
|
+
* @param key - The pacer key, matching the key used in `worker.pacer()`.
|
|
9
|
+
*/
|
|
10
|
+
wait: pacerWait
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
Pacer
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pacer.test.d.ts","sourceRoot":"","sources":["../src/pacer.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pacer_internal.d.ts","sourceRoot":"","sources":["../src/pacer_internal.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,UAAU,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC,CAAC;AAIF,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAErD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let pacerState = { pacers: {} };
|
|
2
|
+
function setPacerState(state) {
|
|
3
|
+
pacerState = state;
|
|
4
|
+
}
|
|
5
|
+
function getPacerState() {
|
|
6
|
+
return pacerState;
|
|
7
|
+
}
|
|
8
|
+
async function pacerWait(key) {
|
|
9
|
+
const state = getPacerState();
|
|
10
|
+
const entry = state.pacers[key];
|
|
11
|
+
if (!entry) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Pacer "${key}" not found. Make sure you declared it with worker.pacer("${key}", ...) and are running inside the worker runtime.`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
const { allowedRequests, intervalMs } = entry;
|
|
17
|
+
const paceMs = Math.ceil(intervalMs / allowedRequests);
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
const lastScheduledAtMs = entry.lastScheduledAtMs;
|
|
20
|
+
const scheduledAtMs = Math.max(lastScheduledAtMs + paceMs, now);
|
|
21
|
+
const delayMs = scheduledAtMs - now;
|
|
22
|
+
state.pacers[key] = { ...entry, lastScheduledAtMs: scheduledAtMs };
|
|
23
|
+
setPacerState(state);
|
|
24
|
+
if (delayMs > 0) {
|
|
25
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
getPacerState,
|
|
30
|
+
pacerWait,
|
|
31
|
+
setPacerState
|
|
32
|
+
};
|
package/dist/schema.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export type PropertyConfiguration = {
|
|
|
48
48
|
} | {
|
|
49
49
|
type: "relation";
|
|
50
50
|
/**
|
|
51
|
-
* The export name of the sync capability that defines the related
|
|
51
|
+
* The export name of the sync capability that defines the related database.
|
|
52
52
|
* This must match the export name used when defining the related sync capability.
|
|
53
53
|
*/
|
|
54
54
|
relatedSyncKey: string;
|
|
@@ -60,13 +60,6 @@ export type PropertyConfiguration = {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
export type Schema<PK extends string> = {
|
|
63
|
-
/**
|
|
64
|
-
* The default name for the database when it is first created.
|
|
65
|
-
*
|
|
66
|
-
* Updating this after the database has been created will not change the
|
|
67
|
-
* name of the database.
|
|
68
|
-
*/
|
|
69
|
-
defaultName: string;
|
|
70
63
|
/**
|
|
71
64
|
* Optional icon to use as the icon for the database page.
|
|
72
65
|
* If not provided, defaults to 📋.
|
|
@@ -151,9 +144,9 @@ export declare function people(): PropertyConfiguration;
|
|
|
151
144
|
export declare function place(): PropertyConfiguration;
|
|
152
145
|
/**
|
|
153
146
|
* Creates a relation property definition that references another sync capability.
|
|
154
|
-
* The related
|
|
147
|
+
* The related database must be defined by a sync capability in the same worker.
|
|
155
148
|
*
|
|
156
|
-
* @param relatedSyncKey - The export name of the sync capability that defines the related
|
|
149
|
+
* @param relatedSyncKey - The export name of the sync capability that defines the related database.
|
|
157
150
|
* @example
|
|
158
151
|
* ```typescript
|
|
159
152
|
* export const projectsSync = sync({...});
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,YAA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CAAC,EAAE,YAAY,GAAG,qBAAqB,CAEnE;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,qBAAqB,CAEpE;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,qBAAqB,CAErE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,qBAAqB,CAE1E;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;CACtB,GAAG,qBAAqB,CAExB;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,qBAAqB,CAE9C;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,qBAAqB,CAE7C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CACvB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,GACxE,qBAAqB,CAMvB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -171,7 +171,7 @@ export type RelationReference = {
|
|
|
171
171
|
};
|
|
172
172
|
/**
|
|
173
173
|
* Relation value representing references to related records.
|
|
174
|
-
* Each reference identifies a record in the target
|
|
174
|
+
* Each reference identifies a record in the target database.
|
|
175
175
|
*/
|
|
176
176
|
export type RelationValue = RelationReference[];
|
|
177
177
|
/**
|
|
@@ -188,14 +188,17 @@ export type IntervalString = `${number}${TimeUnit}`;
|
|
|
188
188
|
/**
|
|
189
189
|
* Schedule configuration for sync capabilities.
|
|
190
190
|
* - "continuous": Run as frequently as the system allows
|
|
191
|
+
* - "manual": Only run when explicitly triggered
|
|
191
192
|
* - IntervalString: Run at specified intervals, e.g. "30m", "1h", "1d"
|
|
192
193
|
*/
|
|
193
|
-
export type Schedule = "continuous" | IntervalString;
|
|
194
|
+
export type Schedule = "continuous" | "manual" | IntervalString;
|
|
194
195
|
/**
|
|
195
196
|
* Normalized schedule representation stored in the backend.
|
|
196
197
|
*/
|
|
197
198
|
export type SyncSchedule = {
|
|
198
199
|
type: "continuous";
|
|
200
|
+
} | {
|
|
201
|
+
type: "manual";
|
|
199
202
|
} | {
|
|
200
203
|
type: "interval";
|
|
201
204
|
intervalMs: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEhC;;;GAGG;AACH,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,WAAW,GACpB,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,KAAK,CAAC;AAET;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,YAAY,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,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