@sequenceholdings/managed-functions 0.2.0 → 0.3.1

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.
@@ -0,0 +1,2 @@
1
+ export declare function concreteOrStaleSdkSpec(spec: string | undefined, minimum: string): string | null;
2
+ export declare function sdkConstraintIsOlder(declared: string, minimum: string): boolean;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.concreteOrStaleSdkSpec = concreteOrStaleSdkSpec;
4
+ exports.sdkConstraintIsOlder = sdkConstraintIsOlder;
5
+ function parseSemver(raw) {
6
+ const match = /^v?(\d+)\.(\d+)\.(\d+)$/.exec(raw.trim());
7
+ if (!match)
8
+ return null;
9
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
10
+ }
11
+ function compare(left, right) {
12
+ for (let index = 0; index < 3; index += 1) {
13
+ const diff = left[index] - right[index];
14
+ if (diff !== 0)
15
+ return diff;
16
+ }
17
+ return 0;
18
+ }
19
+ function caretCeiling(version) {
20
+ const [major, minor, patch] = version;
21
+ if (major > 0)
22
+ return [major + 1, 0, 0];
23
+ if (minor > 0)
24
+ return [major, minor + 1, 0];
25
+ return [major, minor, patch + 1];
26
+ }
27
+ function openBounds() {
28
+ return { min: [0, 0, 0], minInclusive: true, max: null, maxInclusive: false };
29
+ }
30
+ function raiseFloor(bounds, version, inclusive) {
31
+ const diff = compare(version, bounds.min);
32
+ if (diff > 0 || (diff === 0 && bounds.minInclusive && !inclusive)) {
33
+ bounds.min = version;
34
+ bounds.minInclusive = inclusive;
35
+ }
36
+ }
37
+ function lowerCeiling(bounds, version, inclusive) {
38
+ if (!bounds.max) {
39
+ bounds.max = version;
40
+ bounds.maxInclusive = inclusive;
41
+ return;
42
+ }
43
+ const diff = compare(version, bounds.max);
44
+ if (diff < 0 || (diff === 0 && bounds.maxInclusive && !inclusive)) {
45
+ bounds.max = version;
46
+ bounds.maxInclusive = inclusive;
47
+ }
48
+ }
49
+ function applyComparator(bounds, token) {
50
+ const match = /^(>=|<=|>|<|\^|~|=)?v?(\d+\.\d+\.\d+)$/.exec(token);
51
+ if (!match)
52
+ return false;
53
+ const version = parseSemver(match[2]);
54
+ if (!version)
55
+ return false;
56
+ const operator = match[1] ?? '=';
57
+ if (operator === '=') {
58
+ raiseFloor(bounds, version, true);
59
+ lowerCeiling(bounds, version, true);
60
+ }
61
+ else if (operator === '>' || operator === '>=') {
62
+ raiseFloor(bounds, version, operator === '>=');
63
+ }
64
+ else if (operator === '<' || operator === '<=') {
65
+ lowerCeiling(bounds, version, operator === '<=');
66
+ }
67
+ else if (operator === '^') {
68
+ raiseFloor(bounds, version, true);
69
+ lowerCeiling(bounds, caretCeiling(version), false);
70
+ }
71
+ else if (operator === '~') {
72
+ raiseFloor(bounds, version, true);
73
+ lowerCeiling(bounds, [version[0], version[1] + 1, 0], false);
74
+ }
75
+ else {
76
+ return false;
77
+ }
78
+ return true;
79
+ }
80
+ function clauseBounds(clause) {
81
+ const hyphen = /^v?(\d+\.\d+\.\d+)\s+-\s+v?(\d+\.\d+\.\d+)$/.exec(clause.trim());
82
+ if (hyphen) {
83
+ const low = parseSemver(hyphen[1]);
84
+ const high = parseSemver(hyphen[2]);
85
+ if (!low || !high)
86
+ return null;
87
+ const bounds = openBounds();
88
+ raiseFloor(bounds, low, true);
89
+ lowerCeiling(bounds, high, true);
90
+ return bounds;
91
+ }
92
+ const bounds = openBounds();
93
+ for (const token of clause.trim().split(/\s+/)) {
94
+ if (token.length === 0)
95
+ continue;
96
+ if (!applyComparator(bounds, token))
97
+ return null;
98
+ }
99
+ return bounds;
100
+ }
101
+ function clauseIsEntirelyOlder(clause, minimum) {
102
+ const bounds = clauseBounds(clause);
103
+ if (!bounds)
104
+ return null;
105
+ if (!bounds.max)
106
+ return false;
107
+ if (compare(bounds.min, bounds.max) > 0)
108
+ return true;
109
+ const diff = compare(bounds.max, minimum);
110
+ if (diff < 0)
111
+ return true;
112
+ return diff === 0 && !bounds.maxInclusive;
113
+ }
114
+ function concreteOrStaleSdkSpec(spec, minimum) {
115
+ if (!spec)
116
+ return null;
117
+ const trimmed = spec.trim();
118
+ if (trimmed === '' || trimmed === '*' || trimmed === 'latest' || trimmed.startsWith('workspace:')) {
119
+ return null;
120
+ }
121
+ const exact = /^=?v?(\d+\.\d+\.\d+)$/.exec(trimmed);
122
+ if (exact)
123
+ return exact[1] ?? null;
124
+ const target = parseSemver(minimum);
125
+ if (!target)
126
+ return null;
127
+ const alternatives = trimmed.split('||').map((part) => part.trim()).filter((part) => part.length > 0);
128
+ if (alternatives.length === 0)
129
+ return null;
130
+ for (const alternative of alternatives) {
131
+ const older = clauseIsEntirelyOlder(alternative, target);
132
+ if (older !== true)
133
+ return null;
134
+ }
135
+ return trimmed;
136
+ }
137
+ function sdkConstraintIsOlder(declared, minimum) {
138
+ if (/^v?\d+\.\d+\.\d+$/.test(declared)) {
139
+ const installed = parseSemver(declared);
140
+ const required = parseSemver(minimum);
141
+ if (!installed || !required)
142
+ return false;
143
+ return compare(installed, required) < 0;
144
+ }
145
+ return concreteOrStaleSdkSpec(declared, minimum) === declared;
146
+ }
package/dist/storage.d.ts CHANGED
@@ -6,6 +6,15 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
6
6
  capabilities: () => Promise<{
7
7
  canProvision: boolean;
8
8
  uploadMethods: string[];
9
+ pendingUploads: {
10
+ perPrincipal: number;
11
+ perWorkspace: number;
12
+ };
13
+ uploadBatchLimit: number;
14
+ importConcurrency: {
15
+ default: number;
16
+ max: number;
17
+ };
9
18
  }>;
10
19
  list: (options?: import("@sequenceholdings/storage").StorageListOptions) => Promise<{
11
20
  items: {
@@ -369,6 +378,73 @@ export declare function createFunctionStorageClient({ baseUrl, headers, mode, }:
369
378
  versionId: string | null;
370
379
  maxBytes: number;
371
380
  }>;
381
+ startBatch: (items: import("@sequenceholdings/storage").StartStorageUpload[]) => Promise<{
382
+ items: {
383
+ id: string;
384
+ fileId: string;
385
+ uploadUrl: string | null;
386
+ expiresAt: string;
387
+ state: "pending" | "complete" | "aborted";
388
+ versionId: string | null;
389
+ maxBytes: number;
390
+ }[];
391
+ }>;
392
+ list: () => Promise<{
393
+ items: {
394
+ id: string;
395
+ fileId: string;
396
+ name: string;
397
+ state: "pending" | "complete" | "aborted";
398
+ expiresAt: string;
399
+ maxBytes: number;
400
+ expectedSize: number | null;
401
+ versionId: string | null;
402
+ }[];
403
+ limits: {
404
+ perPrincipal: number;
405
+ perWorkspace: number;
406
+ };
407
+ }>;
408
+ reconcile: (input?: {
409
+ abortIncomplete?: boolean;
410
+ }) => Promise<{
411
+ completed: {
412
+ id: string;
413
+ fileId: string;
414
+ name: string;
415
+ state: "pending" | "complete" | "aborted";
416
+ expiresAt: string;
417
+ maxBytes: number;
418
+ expectedSize: number | null;
419
+ versionId: string | null;
420
+ code: string;
421
+ message: string;
422
+ }[];
423
+ aborted: {
424
+ id: string;
425
+ fileId: string;
426
+ name: string;
427
+ state: "pending" | "complete" | "aborted";
428
+ expiresAt: string;
429
+ maxBytes: number;
430
+ expectedSize: number | null;
431
+ versionId: string | null;
432
+ code: string;
433
+ message: string;
434
+ }[];
435
+ pending: {
436
+ id: string;
437
+ fileId: string;
438
+ name: string;
439
+ state: "pending" | "complete" | "aborted";
440
+ expiresAt: string;
441
+ maxBytes: number;
442
+ expectedSize: number | null;
443
+ versionId: string | null;
444
+ code: string;
445
+ message: string;
446
+ }[];
447
+ }>;
372
448
  resume(id: string, source: import("@sequenceholdings/storage").StorageUploadSource, options?: import("@sequenceholdings/storage").StorageTransferOptions & {
373
449
  size?: number;
374
450
  }): Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/managed-functions",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Managed Function context and opt-in cache runtime",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",
@@ -48,7 +48,7 @@
48
48
  "vitest": "^4.1.11",
49
49
  "esbuild": "^0.25.0",
50
50
  "tsup": "^8.3.0",
51
- "@sequenceholdings/orm": "2.1.1"
51
+ "@sequenceholdings/orm": "2.3.0"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=20"