@ductape/sdk 0.3.1 → 0.3.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.
- package/dist/api/services/logsApi.service.d.ts +2 -0
- package/dist/api/services/logsApi.service.js +8 -0
- package/dist/api/services/logsApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +1 -0
- package/dist/api/urls.js +4 -3
- package/dist/api/urls.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +1 -1
- package/dist/apps/services/app.service.js +18 -2
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/clients/interceptors.d.ts +1 -0
- package/dist/clients/interceptors.js +39 -0
- package/dist/clients/interceptors.js.map +1 -1
- package/dist/database/actions/action-manager.d.ts +5 -1
- package/dist/database/actions/action-manager.js +1 -0
- package/dist/database/actions/action-manager.js.map +1 -1
- package/dist/database/databases.service.d.ts +5 -1
- package/dist/database/databases.service.js +3 -1
- package/dist/database/databases.service.js.map +1 -1
- package/dist/database/migrations/migration-engine.d.ts +4 -1
- package/dist/database/migrations/migration-engine.js +55 -8
- package/dist/database/migrations/migration-engine.js.map +1 -1
- package/dist/database/types/migration.interface.d.ts +8 -0
- package/dist/functions/functions.runtime.js +21 -0
- package/dist/functions/functions.runtime.js.map +1 -1
- package/dist/functions/types.d.ts +2 -0
- package/dist/functions/types.js.map +1 -1
- package/dist/index.d.ts +19 -27
- package/dist/index.js +54 -5
- package/dist/index.js.map +1 -1
- package/dist/logs/logs.service.d.ts +1 -0
- package/dist/logs/logs.service.js +12 -2
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/logs/logs.types.d.ts +16 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +2 -2
- package/dist/products/services/products.service.js +3 -0
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/resilience/healthcheck-interval.d.ts +7 -0
- package/dist/resilience/healthcheck-interval.js +27 -0
- package/dist/resilience/healthcheck-interval.js.map +1 -0
- package/dist/resilience/healthcheck.service.js +14 -13
- package/dist/resilience/healthcheck.service.js.map +1 -1
- package/dist/resilience/types/index.d.ts +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/inputs.types.js +2 -1
- package/dist/types/inputs.types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { FeatureService } from './features';
|
|
|
9
9
|
import { type IPortableFunctionContract } from './functions';
|
|
10
10
|
export * from './context';
|
|
11
11
|
export * from './resilience';
|
|
12
|
+
import type { IUploadOptions, IDeleteOptions, ISignedUrlOptions } from './storage';
|
|
12
13
|
import { BrokersService } from './brokers';
|
|
13
14
|
import { IHealthcheckDefineOptions, IDefinedHealthcheck, IQuotaDefineOptions, IDefinedQuota, IFallbackDefineOptions, IDefinedFallback, IRateLimitDefinition, IRateLimitConsumeInput } from './resilience';
|
|
14
15
|
import { AgentsService } from './agents';
|
|
@@ -370,7 +371,7 @@ export default class Ductape implements IDuctape {
|
|
|
370
371
|
private scheduleAllHealthcheckJobs;
|
|
371
372
|
/**
|
|
372
373
|
* Schedules a single healthcheck job with the given interval (ms).
|
|
373
|
-
*
|
|
374
|
+
* The caller supplies the probe-aware default when no explicit interval exists.
|
|
374
375
|
*/
|
|
375
376
|
private scheduleHealthcheckJob;
|
|
376
377
|
setUserId(user_id: string): void;
|
|
@@ -1027,14 +1028,7 @@ export default class Ductape implements IDuctape {
|
|
|
1027
1028
|
* @param data - The upload options.
|
|
1028
1029
|
* @returns The upload result with file URL.
|
|
1029
1030
|
*/
|
|
1030
|
-
upload: (data:
|
|
1031
|
-
product: string;
|
|
1032
|
-
env: string;
|
|
1033
|
-
storage: string;
|
|
1034
|
-
fileName: string;
|
|
1035
|
-
buffer: string | Buffer;
|
|
1036
|
-
mimeType?: string;
|
|
1037
|
-
}) => Promise<import("./storage").IStorageResult>;
|
|
1031
|
+
upload: (data: IUploadOptions) => Promise<import("./storage").IStorageResult>;
|
|
1038
1032
|
/**
|
|
1039
1033
|
* Downloads a file from cloud storage (top-level convenience method).
|
|
1040
1034
|
* @param data - The download options.
|
|
@@ -1051,12 +1045,7 @@ export default class Ductape implements IDuctape {
|
|
|
1051
1045
|
* @param data - The delete options.
|
|
1052
1046
|
* @returns The delete result.
|
|
1053
1047
|
*/
|
|
1054
|
-
remove: (data:
|
|
1055
|
-
product: string;
|
|
1056
|
-
env: string;
|
|
1057
|
-
storage: string;
|
|
1058
|
-
fileName: string;
|
|
1059
|
-
}) => Promise<import("./storage").IDeleteResult>;
|
|
1048
|
+
remove: (data: IDeleteOptions) => Promise<import("./storage").IDeleteResult>;
|
|
1060
1049
|
/**
|
|
1061
1050
|
* Lists files in cloud storage with pagination (top-level convenience method).
|
|
1062
1051
|
* @param data - The list options.
|
|
@@ -1076,14 +1065,7 @@ export default class Ductape implements IDuctape {
|
|
|
1076
1065
|
* @param data - The signed URL options.
|
|
1077
1066
|
* @returns The signed URL result.
|
|
1078
1067
|
*/
|
|
1079
|
-
getSignedUrl: (data:
|
|
1080
|
-
product: string;
|
|
1081
|
-
env: string;
|
|
1082
|
-
storage: string;
|
|
1083
|
-
fileName: string;
|
|
1084
|
-
expiresIn?: number;
|
|
1085
|
-
action?: "read" | "write";
|
|
1086
|
-
}) => Promise<import("./storage").ISignedUrlResult>;
|
|
1068
|
+
getSignedUrl: (data: ISignedUrlOptions) => Promise<import("./storage").ISignedUrlResult>;
|
|
1087
1069
|
/**
|
|
1088
1070
|
* Gets storage statistics (file counts and sizes by type).
|
|
1089
1071
|
* Efficiently counts all files without downloading content.
|
|
@@ -2066,7 +2048,11 @@ export default class Ductape implements IDuctape {
|
|
|
2066
2048
|
update: (options: IActionUpdateOptions) => Promise<void>;
|
|
2067
2049
|
fetch: (tag: string) => Promise<import("./database").IActionDefinition>;
|
|
2068
2050
|
list: (databaseTag: string) => Promise<import("./database").IActionDefinition[]>;
|
|
2069
|
-
delete: (tag: string) => Promise<
|
|
2051
|
+
delete: (tag: string) => Promise<{
|
|
2052
|
+
tag: string;
|
|
2053
|
+
deleted: true;
|
|
2054
|
+
mutationState: "confirmed";
|
|
2055
|
+
}>;
|
|
2070
2056
|
dispatch: (data: IDBActionDispatchInput) => Promise<IDispatchResult>;
|
|
2071
2057
|
};
|
|
2072
2058
|
/**
|
|
@@ -3919,7 +3905,7 @@ export default class Ductape implements IDuctape {
|
|
|
3919
3905
|
resource: string;
|
|
3920
3906
|
method: string;
|
|
3921
3907
|
folder_id?: string;
|
|
3922
|
-
}) => Promise<
|
|
3908
|
+
}) => Promise<IAppAction>;
|
|
3923
3909
|
/**
|
|
3924
3910
|
* Fetches all actions for an app.
|
|
3925
3911
|
* @param {string} appTag - The app tag.
|
|
@@ -4089,7 +4075,7 @@ export default class Ductape implements IDuctape {
|
|
|
4089
4075
|
resource: string;
|
|
4090
4076
|
method: string;
|
|
4091
4077
|
folder_id?: string;
|
|
4092
|
-
}) => Promise<
|
|
4078
|
+
}) => Promise<IAppAction>;
|
|
4093
4079
|
/**
|
|
4094
4080
|
* Fetches all actions for an app.
|
|
4095
4081
|
* @param {string} appTag - The app tag.
|
|
@@ -4348,9 +4334,15 @@ export default class Ductape implements IDuctape {
|
|
|
4348
4334
|
* @returns {Promise<any>} The fetched log data.
|
|
4349
4335
|
*/
|
|
4350
4336
|
fetch: (params: LogQueryParams) => Promise<any>;
|
|
4337
|
+
productObservability: (productTag: string, params?: Record<string, unknown>) => Promise<any>;
|
|
4351
4338
|
publish: () => Promise<void>;
|
|
4352
4339
|
};
|
|
4353
4340
|
private initUserAuth;
|
|
4341
|
+
/** Treat malformed/opaque tokens as usable, but proactively renew JWTs that
|
|
4342
|
+
* expire within the next minute so background workers never begin with a
|
|
4343
|
+
* credential that can expire mid-probe. */
|
|
4344
|
+
private accessTokenNeedsRefresh;
|
|
4345
|
+
private invalidateAuthBoundServices;
|
|
4354
4346
|
private performUserAuth;
|
|
4355
4347
|
private runtimeAuth;
|
|
4356
4348
|
private applyRuntimeSnapshot;
|
|
@@ -4389,7 +4381,7 @@ export default class Ductape implements IDuctape {
|
|
|
4389
4381
|
refreshedAt?: number;
|
|
4390
4382
|
error?: string;
|
|
4391
4383
|
};
|
|
4392
|
-
connections: "
|
|
4384
|
+
connections: "ready" | "warming" | "degraded";
|
|
4393
4385
|
};
|
|
4394
4386
|
warmup: {
|
|
4395
4387
|
databases: {
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ const types_1 = require("./types");
|
|
|
64
64
|
const index_types_1 = require("./types/index.types");
|
|
65
65
|
const runtime_defaults_1 = require("./runtime/runtime-defaults");
|
|
66
66
|
const healthcheck_cache_key_1 = require("./resilience/healthcheck-cache-key");
|
|
67
|
+
const healthcheck_interval_1 = require("./resilience/healthcheck-interval");
|
|
67
68
|
const enums_1 = require("./types/enums");
|
|
68
69
|
const productsApi_service_1 = require("./api/services/productsApi.service");
|
|
69
70
|
const bootstrap_cache_1 = require("./products/bootstrap-cache");
|
|
@@ -5414,6 +5415,11 @@ class Ductape {
|
|
|
5414
5415
|
throw new Error(error);
|
|
5415
5416
|
}
|
|
5416
5417
|
},
|
|
5418
|
+
productObservability: async (productTag, params = {}) => {
|
|
5419
|
+
if (!this.loggerService)
|
|
5420
|
+
this.loggerService = this.createNewLogger();
|
|
5421
|
+
return this.loggerService.productObservability(productTag, params);
|
|
5422
|
+
},
|
|
5417
5423
|
publish: async () => { },
|
|
5418
5424
|
};
|
|
5419
5425
|
if (typeof window !== 'undefined') {
|
|
@@ -5606,6 +5612,7 @@ class Ductape {
|
|
|
5606
5612
|
* Schedules all healthcheck jobs for all products and environments.
|
|
5607
5613
|
*/
|
|
5608
5614
|
async scheduleAllHealthcheckJobs() {
|
|
5615
|
+
var _a, _b;
|
|
5609
5616
|
// Fetch all products (or use this.products if already loaded)
|
|
5610
5617
|
const products = this.products ||
|
|
5611
5618
|
(await this.productsApi.fetchWorkspaceProducts(enums_1.PublicStates.ALL, {
|
|
@@ -5636,7 +5643,7 @@ class Ductape {
|
|
|
5636
5643
|
tag: healthcheck.tag,
|
|
5637
5644
|
};
|
|
5638
5645
|
const jobId = `healthcheck-exec-${healthcheck.tag}-${env.slug}`;
|
|
5639
|
-
await this.scheduleHealthcheckJob(jobId, jobData, healthcheck.interval);
|
|
5646
|
+
await this.scheduleHealthcheckJob(jobId, jobData, (_a = healthcheck.interval) !== null && _a !== void 0 ? _a : (0, healthcheck_interval_1.defaultHealthcheckIntervalMs)((_b = healthcheck.probe) === null || _b === void 0 ? void 0 : _b.type));
|
|
5640
5647
|
scheduledCount++;
|
|
5641
5648
|
}
|
|
5642
5649
|
}
|
|
@@ -5645,14 +5652,14 @@ class Ductape {
|
|
|
5645
5652
|
}
|
|
5646
5653
|
/**
|
|
5647
5654
|
* Schedules a single healthcheck job with the given interval (ms).
|
|
5648
|
-
*
|
|
5655
|
+
* The caller supplies the probe-aware default when no explicit interval exists.
|
|
5649
5656
|
*/
|
|
5650
5657
|
async scheduleHealthcheckJob(jobId, jobData, interval) {
|
|
5651
5658
|
const job = await this.healthCheckQueue.getJob(jobId);
|
|
5652
5659
|
if (job) {
|
|
5653
5660
|
await job.remove();
|
|
5654
5661
|
}
|
|
5655
|
-
const repeat =
|
|
5662
|
+
const repeat = { every: interval !== null && interval !== void 0 ? interval : (0, healthcheck_interval_1.defaultHealthcheckIntervalMs)() };
|
|
5656
5663
|
await this.healthCheckQueue.add('healthchecks-updater', jobData, { repeat, jobId });
|
|
5657
5664
|
}
|
|
5658
5665
|
setUserId(user_id) {
|
|
@@ -5726,16 +5733,56 @@ class Ductape {
|
|
|
5726
5733
|
this.authInFlight = this.performUserAuth(subCheck).finally(() => { this.authInFlight = undefined; });
|
|
5727
5734
|
return await this.authInFlight;
|
|
5728
5735
|
}
|
|
5736
|
+
/** Treat malformed/opaque tokens as usable, but proactively renew JWTs that
|
|
5737
|
+
* expire within the next minute so background workers never begin with a
|
|
5738
|
+
* credential that can expire mid-probe. */
|
|
5739
|
+
accessTokenNeedsRefresh(token) {
|
|
5740
|
+
if (!token)
|
|
5741
|
+
return true;
|
|
5742
|
+
try {
|
|
5743
|
+
const payload = token.split('.')[1];
|
|
5744
|
+
if (!payload)
|
|
5745
|
+
return false;
|
|
5746
|
+
const normalized = payload.replace(/-/g, '+').replace(/_/g, '/');
|
|
5747
|
+
const decoded = JSON.parse(Buffer.from(normalized, 'base64').toString('utf8'));
|
|
5748
|
+
return typeof decoded.exp === 'number' && decoded.exp * 1000 <= Date.now() + 60000;
|
|
5749
|
+
}
|
|
5750
|
+
catch (_a) {
|
|
5751
|
+
return false;
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
async invalidateAuthBoundServices() {
|
|
5755
|
+
var _a;
|
|
5756
|
+
await ((_a = this._databaseService) === null || _a === void 0 ? void 0 : _a.closeAll().catch(() => undefined));
|
|
5757
|
+
this.productBuilders.clear();
|
|
5758
|
+
this.appBuilders.clear();
|
|
5759
|
+
this._databaseService = null;
|
|
5760
|
+
this._graphService = null;
|
|
5761
|
+
this._featureService = null;
|
|
5762
|
+
this._agentsService = null;
|
|
5763
|
+
this._modelService = null;
|
|
5764
|
+
this._vectorService = null;
|
|
5765
|
+
this._warehouseService = null;
|
|
5766
|
+
this._cacheService = null;
|
|
5767
|
+
this._secretsService = null;
|
|
5768
|
+
this._cloudService = null;
|
|
5769
|
+
this._sessionsService = null;
|
|
5770
|
+
this._quotaService = null;
|
|
5771
|
+
this._fallbackService = null;
|
|
5772
|
+
this._healthcheckService = null;
|
|
5773
|
+
this._brokersService = null;
|
|
5774
|
+
}
|
|
5729
5775
|
async performUserAuth(subCheck = true) {
|
|
5730
5776
|
var _a, _b;
|
|
5731
5777
|
// Skip if already authenticated with valid credentials
|
|
5732
|
-
if (this.token && this.public_key) {
|
|
5778
|
+
if (this.token && this.public_key && !this.accessTokenNeedsRefresh(this.token)) {
|
|
5733
5779
|
if (this.runtimeSyncEnabled && !this.runtimeManifest)
|
|
5734
5780
|
await this.refreshRuntimeSnapshot(true);
|
|
5735
5781
|
return;
|
|
5736
5782
|
}
|
|
5737
5783
|
// Only reset if we need to re-authenticate
|
|
5738
|
-
if (!this.token || !this.public_key) {
|
|
5784
|
+
if (!this.token || !this.public_key || this.accessTokenNeedsRefresh(this.token)) {
|
|
5785
|
+
const hadAuthenticatedServices = Boolean(this.token && this.public_key);
|
|
5739
5786
|
this.token = null;
|
|
5740
5787
|
this.public_key = null;
|
|
5741
5788
|
this.session = null;
|
|
@@ -5744,6 +5791,8 @@ class Ductape {
|
|
|
5744
5791
|
await this.refreshUserAccessToken();
|
|
5745
5792
|
await this.createNewAppBuilderSession();
|
|
5746
5793
|
}
|
|
5794
|
+
if (hadAuthenticatedServices)
|
|
5795
|
+
await this.invalidateAuthBoundServices();
|
|
5747
5796
|
}
|
|
5748
5797
|
try {
|
|
5749
5798
|
//await this.validateWorkspace(subCheck);
|