@cadenza.io/service 2.17.26 → 2.17.28
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/browser/index.js +33 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +33 -8
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +55 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6524,6 +6524,11 @@ function resolveDataRows(data) {
|
|
|
6524
6524
|
}
|
|
6525
6525
|
return [ensurePlainObject(data, "data")];
|
|
6526
6526
|
}
|
|
6527
|
+
function buildAddConstraintIfMissingStatement(tableName, constraintName, constraintDefinition) {
|
|
6528
|
+
const escapedConstraintName = constraintName.replace(/'/g, "''");
|
|
6529
|
+
const escapedTableName = tableName.replace(/'/g, "''");
|
|
6530
|
+
return `DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = '${escapedConstraintName}' AND conrelid = '${escapedTableName}'::regclass) THEN ALTER TABLE ${tableName} ADD CONSTRAINT ${constraintName} ${constraintDefinition}; END IF; END $$;`;
|
|
6531
|
+
}
|
|
6527
6532
|
var DatabaseController = class _DatabaseController {
|
|
6528
6533
|
constructor() {
|
|
6529
6534
|
this.registrationsByActorName = /* @__PURE__ */ new Map();
|
|
@@ -7409,22 +7414,33 @@ var DatabaseController = class _DatabaseController {
|
|
|
7409
7414
|
);
|
|
7410
7415
|
}
|
|
7411
7416
|
if (table.primaryKey) {
|
|
7417
|
+
const primaryKeyName = `pk_${tableName}_${table.primaryKey.join("_")}`;
|
|
7412
7418
|
ddl.push(
|
|
7413
|
-
|
|
7414
|
-
|
|
7419
|
+
buildAddConstraintIfMissingStatement(
|
|
7420
|
+
tableName,
|
|
7421
|
+
primaryKeyName,
|
|
7422
|
+
`PRIMARY KEY (${table.primaryKey.map(snakeCase).join(", ")})`
|
|
7423
|
+
)
|
|
7415
7424
|
);
|
|
7416
7425
|
}
|
|
7417
7426
|
for (const uniqueFields of table.uniqueConstraints ?? []) {
|
|
7427
|
+
const uniqueConstraintName = `uq_${tableName}_${uniqueFields.join("_")}`;
|
|
7418
7428
|
ddl.push(
|
|
7419
|
-
|
|
7420
|
-
|
|
7429
|
+
buildAddConstraintIfMissingStatement(
|
|
7430
|
+
tableName,
|
|
7431
|
+
uniqueConstraintName,
|
|
7432
|
+
`UNIQUE (${uniqueFields.map(snakeCase).join(", ")})`
|
|
7433
|
+
)
|
|
7421
7434
|
);
|
|
7422
7435
|
}
|
|
7423
7436
|
for (const foreignKey of table.foreignKeys ?? []) {
|
|
7424
7437
|
const fkName = `fk_${tableName}_${foreignKey.fields.join("_")}`;
|
|
7425
7438
|
ddl.push(
|
|
7426
|
-
|
|
7427
|
-
|
|
7439
|
+
buildAddConstraintIfMissingStatement(
|
|
7440
|
+
tableName,
|
|
7441
|
+
fkName,
|
|
7442
|
+
`FOREIGN KEY (${foreignKey.fields.map(snakeCase).join(", ")}) REFERENCES ${foreignKey.tableName} (${foreignKey.referenceFields.map(snakeCase).join(", ")})`
|
|
7443
|
+
)
|
|
7428
7444
|
);
|
|
7429
7445
|
}
|
|
7430
7446
|
for (const [triggerName, trigger] of Object.entries(table.triggers ?? {})) {
|
|
@@ -8449,6 +8465,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8449
8465
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
8450
8466
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
8451
8467
|
this.tasksSynced = false;
|
|
8468
|
+
this.actorsSynced = false;
|
|
8452
8469
|
this.signalsSynced = false;
|
|
8453
8470
|
this.intentsSynced = false;
|
|
8454
8471
|
this.routinesSynced = false;
|
|
@@ -8913,13 +8930,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8913
8930
|
);
|
|
8914
8931
|
CadenzaService.createUniqueMetaTask(
|
|
8915
8932
|
"Gather actor registration",
|
|
8916
|
-
() =>
|
|
8933
|
+
() => {
|
|
8934
|
+
this.actorsSynced = true;
|
|
8935
|
+
return true;
|
|
8936
|
+
}
|
|
8917
8937
|
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
8918
8938
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
8919
8939
|
"Split actor task maps",
|
|
8920
8940
|
function* (ctx) {
|
|
8921
8941
|
const task = ctx.task;
|
|
8922
|
-
if (
|
|
8942
|
+
if (!this.tasksSynced || !this.actorsSynced) {
|
|
8943
|
+
return;
|
|
8944
|
+
}
|
|
8945
|
+
if (task.hidden || !task.register || !task.registered) {
|
|
8923
8946
|
return;
|
|
8924
8947
|
}
|
|
8925
8948
|
const metadata = getActorTaskRuntimeMetadata(task.taskFunction);
|
|
@@ -8995,7 +9018,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8995
9018
|
"Split observed signals of task",
|
|
8996
9019
|
(ctx, emit) => {
|
|
8997
9020
|
const task = ctx.task;
|
|
8998
|
-
if (task.hidden || !task.register) return false;
|
|
9021
|
+
if (task.hidden || !task.register || !task.registered) return false;
|
|
8999
9022
|
const serviceName2 = resolveSyncServiceName(task);
|
|
9000
9023
|
if (!serviceName2) {
|
|
9001
9024
|
return false;
|
|
@@ -9115,7 +9138,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9115
9138
|
"Split intents of task",
|
|
9116
9139
|
function(ctx, emit) {
|
|
9117
9140
|
const task = ctx.task;
|
|
9118
|
-
if (task.hidden || !task.register) return false;
|
|
9141
|
+
if (task.hidden || !task.register || !task.registered) return false;
|
|
9119
9142
|
const serviceName2 = resolveSyncServiceName(task);
|
|
9120
9143
|
if (!serviceName2) {
|
|
9121
9144
|
return false;
|
|
@@ -9385,7 +9408,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9385
9408
|
this.registerDeputyRelationshipTask
|
|
9386
9409
|
);
|
|
9387
9410
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9388
|
-
"meta.sync_controller.synced_signals"
|
|
9411
|
+
"meta.sync_controller.synced_signals",
|
|
9412
|
+
"meta.sync_controller.synced_tasks"
|
|
9389
9413
|
).then(
|
|
9390
9414
|
CadenzaService.createMetaTask(
|
|
9391
9415
|
"Ensure signal and task sync ready",
|
|
@@ -9417,7 +9441,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9417
9441
|
}
|
|
9418
9442
|
).then(this.registerSignalToTaskMapTask)
|
|
9419
9443
|
);
|
|
9420
|
-
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9444
|
+
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9445
|
+
"meta.sync_controller.synced_intents",
|
|
9446
|
+
"meta.sync_controller.synced_tasks"
|
|
9447
|
+
).then(
|
|
9421
9448
|
CadenzaService.createMetaTask(
|
|
9422
9449
|
"Ensure intent and task sync ready",
|
|
9423
9450
|
(ctx) => {
|
|
@@ -9448,7 +9475,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9448
9475
|
}
|
|
9449
9476
|
).then(this.registerIntentToTaskMapTask)
|
|
9450
9477
|
);
|
|
9451
|
-
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9478
|
+
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9479
|
+
"meta.sync_controller.synced_actors",
|
|
9480
|
+
"meta.sync_controller.synced_tasks"
|
|
9481
|
+
).then(this.registerActorTaskMapTask);
|
|
9452
9482
|
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
9453
9483
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9454
9484
|
if (!task) {
|
|
@@ -9458,9 +9488,20 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9458
9488
|
...ctx,
|
|
9459
9489
|
task
|
|
9460
9490
|
};
|
|
9461
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9491
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9492
|
+
CadenzaService.createMetaTask(
|
|
9493
|
+
"Ensure actor and task sync ready from task registration",
|
|
9494
|
+
(ctx) => {
|
|
9495
|
+
if (!this.tasksSynced || !this.actorsSynced) {
|
|
9496
|
+
return false;
|
|
9497
|
+
}
|
|
9498
|
+
return ctx;
|
|
9499
|
+
}
|
|
9500
|
+
).then(this.registerActorTaskMapTask)
|
|
9501
|
+
);
|
|
9462
9502
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9463
9503
|
"meta.sync_controller.synced_routines",
|
|
9504
|
+
"meta.sync_controller.synced_tasks",
|
|
9464
9505
|
"meta.sync_controller.task_registered"
|
|
9465
9506
|
).then(
|
|
9466
9507
|
CadenzaService.createMetaTask(
|