zitejs 0.9.121 → 0.9.122
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/cjs/sync/lib.js
CHANGED
|
@@ -1230,10 +1230,10 @@ function generateBackendWrapperTs(envVarNames = []) {
|
|
|
1230
1230
|
"// Auto-generated type-narrowing wrapper. Do not edit manually.",
|
|
1231
1231
|
"// Re-exports createEndpoint with context.user typed to the app User.",
|
|
1232
1232
|
"",
|
|
1233
|
-
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext, ZiteErrorCode, ZiteSchedule, ZiteStreamInterface, ZiteWebhook } from 'zitejs/backend/base';",
|
|
1233
|
+
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext, ZiteErrorCode, ZiteSchedule, ZiteStreamInterface, ZiteTrigger, ZiteWebhook } from 'zitejs/backend/base';",
|
|
1234
1234
|
"import type { User } from 'zitejs/auth';",
|
|
1235
1235
|
"",
|
|
1236
|
-
"export type { ZiteErrorCode, ZiteSchedule, ZiteScheduledContext, ZiteStreamInterface, ZiteWebhook };",
|
|
1236
|
+
"export type { ZiteErrorCode, ZiteSchedule, ZiteScheduledContext, ZiteStreamInterface, ZiteTrigger, ZiteWebhook };",
|
|
1237
1237
|
// The pre-monorepo SDK put this in scope for every endpoint, so migrated
|
|
1238
1238
|
// code can name it. `createEndpoint` infers the same thing without it.
|
|
1239
1239
|
"export type InferSchemaType<T> = T extends { _output: infer U } ? U : T;",
|
|
@@ -1308,7 +1308,7 @@ function generateBackendWrapperTs(envVarNames = []) {
|
|
|
1308
1308
|
// TStream mirrors zitejs/backend/base. Without it `stream: true` endpoints
|
|
1309
1309
|
// get no `stream` argument here — and this wrapper, not the base module, is
|
|
1310
1310
|
// what `zitejs/backend` resolves to in every app.
|
|
1311
|
-
"export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput> {",
|
|
1311
|
+
"export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput, TTrigger extends ZiteTrigger | undefined = undefined> {",
|
|
1312
1312
|
" description?: string;",
|
|
1313
1313
|
" inputSchema?: SchemaLike<TInput, TRawInput>;",
|
|
1314
1314
|
// Apps compile against this copy, not the base module's.
|
|
@@ -1320,17 +1320,19 @@ function generateBackendWrapperTs(envVarNames = []) {
|
|
|
1320
1320
|
" schedule?: TSchedule;",
|
|
1321
1321
|
" /** When set, an inbound webhook can also trigger this endpoint. Like `schedule`, it widens `context` — a webhook fire has no session. */",
|
|
1322
1322
|
" webhook?: TWebhook;",
|
|
1323
|
+
" /** When set, a workspace connection's events (registered by `src/triggers/<endpointId>/subscribe.ts`) or a poll also fire this endpoint. Like `webhook`, it widens `context` — a trigger fire has no session. */",
|
|
1324
|
+
" trigger?: TTrigger;",
|
|
1323
1325
|
" execute: (",
|
|
1324
1326
|
" params: {",
|
|
1325
1327
|
" input: TInput;",
|
|
1326
|
-
" context: TSchedule extends ZiteSchedule ? ZiteRequestContext | ZiteScheduledContext : TWebhook extends ZiteWebhook ? ZiteRequestContext | ZiteScheduledContext : ZiteRequestContext;",
|
|
1328
|
+
" context: TSchedule extends ZiteSchedule ? ZiteRequestContext | ZiteScheduledContext : TWebhook extends ZiteWebhook ? ZiteRequestContext | ZiteScheduledContext : TTrigger extends ZiteTrigger ? ZiteRequestContext | ZiteScheduledContext : ZiteRequestContext;",
|
|
1327
1329
|
" } & (TStream extends true ? { stream: ZiteStreamInterface } : {}),",
|
|
1328
1330
|
" ) => Promise<TOutput> | TOutput;",
|
|
1329
1331
|
"}",
|
|
1330
1332
|
"",
|
|
1331
|
-
"export function createEndpoint<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput>(",
|
|
1332
|
-
" config: EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput>,",
|
|
1333
|
-
"): EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput> {",
|
|
1333
|
+
"export function createEndpoint<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput, TTrigger extends ZiteTrigger | undefined = undefined>(",
|
|
1334
|
+
" config: EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput, TTrigger>,",
|
|
1335
|
+
"): EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput, TTrigger> {",
|
|
1334
1336
|
" return config;",
|
|
1335
1337
|
"}",
|
|
1336
1338
|
"",
|
|
@@ -381,6 +381,11 @@ const duplicateIdentifierErrorsIn = (source) => {
|
|
|
381
381
|
(0, vitest_1.it)('exports createEndpoint', () => {
|
|
382
382
|
(0, vitest_1.expect)(output).toContain('createEndpoint');
|
|
383
383
|
});
|
|
384
|
+
(0, vitest_1.it)('types the trigger field like schedule and webhook', () => {
|
|
385
|
+
(0, vitest_1.expect)(output).toContain('trigger?: TTrigger;');
|
|
386
|
+
(0, vitest_1.expect)(output).toContain('TTrigger extends ZiteTrigger | undefined = undefined');
|
|
387
|
+
(0, vitest_1.expect)(output).toContain('ZiteTrigger, ZiteWebhook }');
|
|
388
|
+
});
|
|
384
389
|
(0, vitest_1.it)('exports ZiteError', () => {
|
|
385
390
|
(0, vitest_1.expect)(output).toContain('ZiteError');
|
|
386
391
|
});
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -1216,10 +1216,10 @@ export function generateBackendWrapperTs(envVarNames = []) {
|
|
|
1216
1216
|
"// Auto-generated type-narrowing wrapper. Do not edit manually.",
|
|
1217
1217
|
"// Re-exports createEndpoint with context.user typed to the app User.",
|
|
1218
1218
|
"",
|
|
1219
|
-
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext, ZiteErrorCode, ZiteSchedule, ZiteStreamInterface, ZiteWebhook } from 'zitejs/backend/base';",
|
|
1219
|
+
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext, ZiteErrorCode, ZiteSchedule, ZiteStreamInterface, ZiteTrigger, ZiteWebhook } from 'zitejs/backend/base';",
|
|
1220
1220
|
"import type { User } from 'zitejs/auth';",
|
|
1221
1221
|
"",
|
|
1222
|
-
"export type { ZiteErrorCode, ZiteSchedule, ZiteScheduledContext, ZiteStreamInterface, ZiteWebhook };",
|
|
1222
|
+
"export type { ZiteErrorCode, ZiteSchedule, ZiteScheduledContext, ZiteStreamInterface, ZiteTrigger, ZiteWebhook };",
|
|
1223
1223
|
// The pre-monorepo SDK put this in scope for every endpoint, so migrated
|
|
1224
1224
|
// code can name it. `createEndpoint` infers the same thing without it.
|
|
1225
1225
|
"export type InferSchemaType<T> = T extends { _output: infer U } ? U : T;",
|
|
@@ -1294,7 +1294,7 @@ export function generateBackendWrapperTs(envVarNames = []) {
|
|
|
1294
1294
|
// TStream mirrors zitejs/backend/base. Without it `stream: true` endpoints
|
|
1295
1295
|
// get no `stream` argument here — and this wrapper, not the base module, is
|
|
1296
1296
|
// what `zitejs/backend` resolves to in every app.
|
|
1297
|
-
"export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput> {",
|
|
1297
|
+
"export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput, TTrigger extends ZiteTrigger | undefined = undefined> {",
|
|
1298
1298
|
" description?: string;",
|
|
1299
1299
|
" inputSchema?: SchemaLike<TInput, TRawInput>;",
|
|
1300
1300
|
// Apps compile against this copy, not the base module's.
|
|
@@ -1306,17 +1306,19 @@ export function generateBackendWrapperTs(envVarNames = []) {
|
|
|
1306
1306
|
" schedule?: TSchedule;",
|
|
1307
1307
|
" /** When set, an inbound webhook can also trigger this endpoint. Like `schedule`, it widens `context` — a webhook fire has no session. */",
|
|
1308
1308
|
" webhook?: TWebhook;",
|
|
1309
|
+
" /** When set, a workspace connection's events (registered by `src/triggers/<endpointId>/subscribe.ts`) or a poll also fire this endpoint. Like `webhook`, it widens `context` — a trigger fire has no session. */",
|
|
1310
|
+
" trigger?: TTrigger;",
|
|
1309
1311
|
" execute: (",
|
|
1310
1312
|
" params: {",
|
|
1311
1313
|
" input: TInput;",
|
|
1312
|
-
" context: TSchedule extends ZiteSchedule ? ZiteRequestContext | ZiteScheduledContext : TWebhook extends ZiteWebhook ? ZiteRequestContext | ZiteScheduledContext : ZiteRequestContext;",
|
|
1314
|
+
" context: TSchedule extends ZiteSchedule ? ZiteRequestContext | ZiteScheduledContext : TWebhook extends ZiteWebhook ? ZiteRequestContext | ZiteScheduledContext : TTrigger extends ZiteTrigger ? ZiteRequestContext | ZiteScheduledContext : ZiteRequestContext;",
|
|
1313
1315
|
" } & (TStream extends true ? { stream: ZiteStreamInterface } : {}),",
|
|
1314
1316
|
" ) => Promise<TOutput> | TOutput;",
|
|
1315
1317
|
"}",
|
|
1316
1318
|
"",
|
|
1317
|
-
"export function createEndpoint<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput>(",
|
|
1318
|
-
" config: EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput>,",
|
|
1319
|
-
"): EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput> {",
|
|
1319
|
+
"export function createEndpoint<TInput = unknown, TOutput = unknown, TStream extends boolean = false, TSchedule extends ZiteSchedule | undefined = undefined, TWebhook extends ZiteWebhook | undefined = undefined, TRawInput = TInput, TTrigger extends ZiteTrigger | undefined = undefined>(",
|
|
1320
|
+
" config: EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput, TTrigger>,",
|
|
1321
|
+
"): EndpointConfig<TInput, TOutput, TStream, TSchedule, TWebhook, TRawInput, TTrigger> {",
|
|
1320
1322
|
" return config;",
|
|
1321
1323
|
"}",
|
|
1322
1324
|
"",
|
|
@@ -376,6 +376,11 @@ describe('generateBackendWrapperTs', () => {
|
|
|
376
376
|
it('exports createEndpoint', () => {
|
|
377
377
|
expect(output).toContain('createEndpoint');
|
|
378
378
|
});
|
|
379
|
+
it('types the trigger field like schedule and webhook', () => {
|
|
380
|
+
expect(output).toContain('trigger?: TTrigger;');
|
|
381
|
+
expect(output).toContain('TTrigger extends ZiteTrigger | undefined = undefined');
|
|
382
|
+
expect(output).toContain('ZiteTrigger, ZiteWebhook }');
|
|
383
|
+
});
|
|
379
384
|
it('exports ZiteError', () => {
|
|
380
385
|
expect(output).toContain('ZiteError');
|
|
381
386
|
});
|