@marcoappio/marco-config 3.0.2 → 3.0.3
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.
|
@@ -534,6 +534,7 @@ export declare const appwriteFunctions: {
|
|
|
534
534
|
method: "POST";
|
|
535
535
|
path: "/polls/run";
|
|
536
536
|
requestSchema: v.StrictObjectSchema<{
|
|
537
|
+
readonly scheduledFor: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>, v.CheckAction<string, undefined>]>;
|
|
537
538
|
readonly shardId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 36, undefined>, v.RegexAction<string, undefined>]>;
|
|
538
539
|
}, undefined>;
|
|
539
540
|
responseSchema: v.StrictObjectSchema<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/appwrite/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAS5B,KAAK,uBAAuB,GAAG,eAAe,GAAG,UAAU,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/appwrite/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAS5B,KAAK,uBAAuB,GAAG,eAAe,GAAG,UAAU,GAAG,SAAS,CAAA;AAuLvE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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S,EAAE,MAAM,CAAC,SAAS;IAAE,aAAa,EAAE,MAAM,OAAO,SAAS,CAAC,CAAC,aAAa,CAAA;CAAE,GACzG,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,GACtB,KAAK,CAAA;AACT,MAAM,MAAM,wBAAwB,CAClC,SAAS,SAAS,oBAAoB,EACtC,MAAM,SAAS,yBAAyB,CAAC,SAAS,CAAC,IACjD,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS;IAAE,cAAc,EAAE,MAAM,OAAO,SAAS,CAAC,CAAC,aAAa,CAAA;CAAE,GAC1G,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,GACtB,KAAK,CAAA"}
|
|
@@ -48,6 +48,10 @@ const connectionResultSchema = v.strictObject({
|
|
|
48
48
|
});
|
|
49
49
|
const completedSchema = v.strictObject({ state: v.literal('COMPLETED') });
|
|
50
50
|
const emptySchema = v.strictObject({});
|
|
51
|
+
const timestampSchema = v.pipe(v.string(), v.isoTimestamp(), v.check(timestamp => {
|
|
52
|
+
const milliseconds = Date.parse(timestamp);
|
|
53
|
+
return Number.isFinite(milliseconds) && new Date(milliseconds).toISOString() === timestamp;
|
|
54
|
+
}));
|
|
51
55
|
const createRoute = (route) => ({
|
|
52
56
|
...route,
|
|
53
57
|
errorSchema: functionErrorSchema,
|
|
@@ -137,7 +141,10 @@ const workerRoutes = {
|
|
|
137
141
|
context: 'internal',
|
|
138
142
|
method: 'POST',
|
|
139
143
|
path: '/polls/run',
|
|
140
|
-
requestSchema: v.strictObject({
|
|
144
|
+
requestSchema: v.strictObject({
|
|
145
|
+
scheduledFor: timestampSchema,
|
|
146
|
+
shardId: appwriteRowIdSchema,
|
|
147
|
+
}),
|
|
141
148
|
responseSchema: completedSchema,
|
|
142
149
|
}),
|
|
143
150
|
supervisor: createRoute({
|
|
@@ -105,7 +105,7 @@ const routeFixtures = [
|
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
name: 'poll runner',
|
|
108
|
-
request: { shardId: 'test-poll-shard-id-1' },
|
|
108
|
+
request: { scheduledFor: '2026-07-23T12:00:30.000Z', shardId: 'test-poll-shard-id-1' },
|
|
109
109
|
response: { state: 'COMPLETED' },
|
|
110
110
|
route: () => appwriteFunctions.worker.routes.pollsRun,
|
|
111
111
|
},
|
|
@@ -179,12 +179,47 @@ describe('appwriteFunctions', () => {
|
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
const workerShardRoutes = [
|
|
182
|
-
{
|
|
183
|
-
|
|
182
|
+
{
|
|
183
|
+
description: 'poll',
|
|
184
|
+
request: { scheduledFor: '2026-07-23T12:00:30.000Z', shardId: 'test invalid shard id' },
|
|
185
|
+
requestSchema: appwriteFunctions.worker.routes.pollsRun.requestSchema,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
description: 'watcher',
|
|
189
|
+
request: { shardId: 'test invalid shard id' },
|
|
190
|
+
requestSchema: appwriteFunctions.worker.routes.watchersRun.requestSchema,
|
|
191
|
+
},
|
|
184
192
|
];
|
|
185
|
-
for (const { description, requestSchema } of workerShardRoutes) {
|
|
193
|
+
for (const { description, request, requestSchema } of workerShardRoutes) {
|
|
186
194
|
it(`rejects a malformed ${description} shard ID`, () => {
|
|
187
|
-
expect(v.safeParse(requestSchema,
|
|
195
|
+
expect(v.safeParse(requestSchema, request).success).toBe(false);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
for (const { description, request } of [
|
|
199
|
+
{ description: 'a missing scheduled slot', request: { shardId: 'test-poll-shard-id-1' } },
|
|
200
|
+
{
|
|
201
|
+
description: 'a malformed scheduled slot',
|
|
202
|
+
request: { scheduledFor: '2026-07-23 12:00:30', shardId: 'test-poll-shard-id-1' },
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
description: 'a calendar-impossible scheduled slot',
|
|
206
|
+
request: { scheduledFor: '2026-06-31T12:00:30.000Z', shardId: 'test-poll-shard-id-1' },
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
description: 'a non-canonical scheduled slot',
|
|
210
|
+
request: { scheduledFor: '2026-07-23T12:00:30.000+00:00', shardId: 'test-poll-shard-id-1' },
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
description: 'an extra field',
|
|
214
|
+
request: {
|
|
215
|
+
scheduledFor: '2026-07-23T12:00:30.000Z',
|
|
216
|
+
shardId: 'test-poll-shard-id-1',
|
|
217
|
+
unexpected: true,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
]) {
|
|
221
|
+
it(`rejects a poll request with ${description}`, () => {
|
|
222
|
+
expect(v.safeParse(appwriteFunctions.worker.routes.pollsRun.requestSchema, request).success).toBe(false);
|
|
188
223
|
});
|
|
189
224
|
}
|
|
190
225
|
it('redacts credentials from connection responses and compact errors', () => {
|