@apotech-os/cli 0.8.0 → 0.9.0
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/index.js +150 -41
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22608,14 +22608,6 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
|
22608
22608
|
return FieldType2;
|
|
22609
22609
|
})(FieldType || {});
|
|
22610
22610
|
var AppVariableTypeSchema = external_exports.enum(["STRING", "NUMBER", "BOOLEAN", "JSON"]);
|
|
22611
|
-
var ApplicationVariableSchema = external_exports.object({
|
|
22612
|
-
universalIdentifier: external_exports.string().uuid(),
|
|
22613
|
-
name: external_exports.string(),
|
|
22614
|
-
description: external_exports.string().optional(),
|
|
22615
|
-
type: AppVariableTypeSchema,
|
|
22616
|
-
value: external_exports.unknown(),
|
|
22617
|
-
isSecret: external_exports.boolean().optional()
|
|
22618
|
-
});
|
|
22619
22611
|
var ServerVariableSchema = external_exports.object({
|
|
22620
22612
|
universalIdentifier: external_exports.string().uuid(),
|
|
22621
22613
|
name: external_exports.string(),
|
|
@@ -22623,10 +22615,6 @@ var ServerVariableSchema = external_exports.object({
|
|
|
22623
22615
|
type: AppVariableTypeSchema,
|
|
22624
22616
|
isRequired: external_exports.boolean().optional()
|
|
22625
22617
|
});
|
|
22626
|
-
var AppHooksSchema = external_exports.object({
|
|
22627
|
-
preInstall: external_exports.string().optional(),
|
|
22628
|
-
postInstall: external_exports.string().optional()
|
|
22629
|
-
});
|
|
22630
22618
|
var RelationDefSchema = external_exports.object({
|
|
22631
22619
|
targetRef: external_exports.string(),
|
|
22632
22620
|
relationType: external_exports.literal("MANY_TO_ONE"),
|
|
@@ -22647,13 +22635,22 @@ var FieldDefSchema = external_exports.object({
|
|
|
22647
22635
|
options: external_exports.array(external_exports.string()).optional(),
|
|
22648
22636
|
relation: RelationDefSchema.optional()
|
|
22649
22637
|
});
|
|
22650
|
-
var
|
|
22638
|
+
var IndexDefFieldsSchema = external_exports.object({
|
|
22651
22639
|
universalIdentifier: external_exports.string(),
|
|
22652
22640
|
// Field names in indexes are subject to the same identifier constraint as FieldDef.name.
|
|
22653
22641
|
fields: external_exports.array(external_exports.string().regex(FIELD_NAME_REGEX, "index field name must be a valid identifier")).min(1),
|
|
22654
22642
|
isUnique: external_exports.boolean().optional(),
|
|
22655
22643
|
aggregateIndex: external_exports.boolean().optional()
|
|
22656
22644
|
});
|
|
22645
|
+
var IndexDefSchema = IndexDefFieldsSchema.superRefine((index, ctx) => {
|
|
22646
|
+
if (index.isUnique && index.aggregateIndex) {
|
|
22647
|
+
ctx.addIssue({
|
|
22648
|
+
code: "custom",
|
|
22649
|
+
path: ["aggregateIndex"],
|
|
22650
|
+
message: "isUnique and aggregateIndex are mutually exclusive on the same IndexDef"
|
|
22651
|
+
});
|
|
22652
|
+
}
|
|
22653
|
+
});
|
|
22657
22654
|
var VIEW_FILTER_OPS = [
|
|
22658
22655
|
"eq",
|
|
22659
22656
|
"neq",
|
|
@@ -22684,11 +22681,15 @@ var ViewDefSchema = external_exports.object({
|
|
|
22684
22681
|
sorts: external_exports.array(ViewSortSchema).optional(),
|
|
22685
22682
|
isDefault: external_exports.boolean().optional()
|
|
22686
22683
|
});
|
|
22684
|
+
var MAX_FUNCTION_RETRIES = 20;
|
|
22687
22685
|
var RESERVED_EVENT_PREFIXES = [
|
|
22688
22686
|
"app-",
|
|
22689
22687
|
"app.",
|
|
22690
22688
|
"shopify.",
|
|
22691
22689
|
"pipedrive.",
|
|
22690
|
+
"klaviyo.",
|
|
22691
|
+
"gorgias.",
|
|
22692
|
+
"platform.",
|
|
22692
22693
|
"app-record."
|
|
22693
22694
|
];
|
|
22694
22695
|
var CUSTOM_EVENT_NAME_REGEX = /^[a-z][a-z0-9]*([.-][a-z0-9]+)*$/;
|
|
@@ -22713,7 +22714,16 @@ var FunctionTriggerSchema = external_exports.discriminatedUnion("type", [
|
|
|
22713
22714
|
type: external_exports.literal("httpRoute"),
|
|
22714
22715
|
path: external_exports.string(),
|
|
22715
22716
|
method: external_exports.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "ALL"]),
|
|
22716
|
-
isAuthRequired: external_exports.boolean().optional()
|
|
22717
|
+
isAuthRequired: external_exports.boolean().optional(),
|
|
22718
|
+
/**
|
|
22719
|
+
* Minimum role the calling session must hold on this app
|
|
22720
|
+
* (contextId = manifest.slug). Defaults to EDITOR — fail-closed, like
|
|
22721
|
+
* `uiInvoke` and for the same reason: the handler runs with the app's FULL
|
|
22722
|
+
* manifest role, not the caller's.
|
|
22723
|
+
* Illegal with `isAuthRequired: false` (webhook mode: there is no session,
|
|
22724
|
+
* the HMAC governs) — rejected by the refinement on FunctionDefSchema.
|
|
22725
|
+
*/
|
|
22726
|
+
minRole: external_exports.enum(["VIEWER", "EDITOR", "ADMIN"]).optional()
|
|
22717
22727
|
}),
|
|
22718
22728
|
external_exports.object({
|
|
22719
22729
|
type: external_exports.literal("event"),
|
|
@@ -22751,7 +22761,25 @@ var FunctionTriggerSchema = external_exports.discriminatedUnion("type", [
|
|
|
22751
22761
|
*/
|
|
22752
22762
|
minRole: external_exports.enum(["VIEWER", "EDITOR", "ADMIN"]).optional(),
|
|
22753
22763
|
/** Wall-clock budget in ms. Clamped server-side by APP_SYNC_INVOKE_MAX_MS. */
|
|
22754
|
-
timeoutMs: external_exports.number().int().min(1e3).max(3e4).optional()
|
|
22764
|
+
timeoutMs: external_exports.number().int().min(1e3).max(3e4).optional(),
|
|
22765
|
+
/**
|
|
22766
|
+
* Bilateral consent (cross-app function calls) — the apps allowed to
|
|
22767
|
+
* invoke this function synchronously with their OWN app token, in
|
|
22768
|
+
* addition to `minRole`-gated human sessions. Entries are `app:<slug>`
|
|
22769
|
+
* for one named app, or the wildcard `'*'` for any installed app.
|
|
22770
|
+
*
|
|
22771
|
+
* Placed on the trigger (next to `minRole`) rather than on the
|
|
22772
|
+
* FunctionDef: both fields answer the same question — "who may reach
|
|
22773
|
+
* this uiInvoke handler" — for two different caller identities (a human
|
|
22774
|
+
* session vs. an app token), so they belong together.
|
|
22775
|
+
*
|
|
22776
|
+
* A caller's own manifest declaring `role.calls` grants it nothing by
|
|
22777
|
+
* itself — only this list does. See `isFunctionExposedTo` and the
|
|
22778
|
+
* consent check in `AppInvokeController`. Optional and additive: an
|
|
22779
|
+
* existing manifest without this field keeps parsing unchanged, and is
|
|
22780
|
+
* treated as exposing the function to no other app.
|
|
22781
|
+
*/
|
|
22782
|
+
exposedToApps: external_exports.array(external_exports.string()).optional()
|
|
22755
22783
|
})
|
|
22756
22784
|
]);
|
|
22757
22785
|
var FunctionDefFieldsSchema = external_exports.object({
|
|
@@ -22759,28 +22787,43 @@ var FunctionDefFieldsSchema = external_exports.object({
|
|
|
22759
22787
|
name: external_exports.string(),
|
|
22760
22788
|
trigger: FunctionTriggerSchema,
|
|
22761
22789
|
/**
|
|
22762
|
-
*
|
|
22763
|
-
*
|
|
22764
|
-
*
|
|
22790
|
+
* Maximum retry attempts for this function (0 = no retries, fail immediately).
|
|
22791
|
+
*
|
|
22792
|
+
* NOT capped at PARSING time on purpose: AppManifestSchema is re-parsed against
|
|
22793
|
+
* manifests already persisted in the DB, so a `.max()` here would break boot for
|
|
22794
|
+
* an app published before the ceiling existed. The rule lives in
|
|
22795
|
+
* `checkManifestSemantics` (authoring / publish) plus a defensive clamp when the
|
|
22796
|
+
* Inngest function is built.
|
|
22765
22797
|
*/
|
|
22766
|
-
retries: external_exports.number().int().min(0).
|
|
22798
|
+
retries: external_exports.number().int().min(0).describe(
|
|
22799
|
+
`Retry attempts, 0..${MAX_FUNCTION_RETRIES} (0 = fail on the first error, absent = 4). Each app function runs as its own Inngest function, so this value is honoured natively; Inngest refuses more than ${MAX_FUNCTION_RETRIES}, so a higher value is rejected at publish time.`
|
|
22800
|
+
).optional(),
|
|
22767
22801
|
/**
|
|
22768
|
-
*
|
|
22769
|
-
*
|
|
22770
|
-
*
|
|
22771
|
-
* cannot attach a per-app-function Inngest concurrency limit because there is no
|
|
22772
|
-
* per-app-function Inngest function. This value is stored in the manifest and
|
|
22773
|
-
* validated, but is NOT enforced at the Inngest level. A warning is logged at app
|
|
22774
|
-
* sync time so operators are aware. Enforcement would require migrating to
|
|
22775
|
-
* per-function Inngest registrations, which is out of scope for P9.
|
|
22802
|
+
* Maximum number of concurrent runs of this function. Enforced by Inngest: each
|
|
22803
|
+
* app function is registered as its own Inngest function, which carries this
|
|
22804
|
+
* limit natively.
|
|
22776
22805
|
*/
|
|
22777
22806
|
concurrency: external_exports.number().int().min(1).optional(),
|
|
22778
22807
|
/**
|
|
22779
|
-
*
|
|
22780
|
-
*
|
|
22781
|
-
* the same app. Cross-manifest validation is enforced by AppSyncService.
|
|
22808
|
+
* Custom EVENT name emitted once when this function fails permanently.
|
|
22809
|
+
* See the `.describe()` below for the full contract.
|
|
22782
22810
|
*/
|
|
22783
|
-
onFailure: external_exports.string().
|
|
22811
|
+
onFailure: external_exports.string().describe(
|
|
22812
|
+
'Custom EVENT name emitted once when this function fails permanently. Must be declared in manifest.emits AND be subscribed to by a function of the same app (trigger: { type: "event", name }). Payload: { appSlug, functionName, error }.'
|
|
22813
|
+
).optional(),
|
|
22814
|
+
/**
|
|
22815
|
+
* Platform end-of-run notification. The platform opens an Inbox alert —
|
|
22816
|
+
* independently of `onFailure`, which stays the APPLICATION channel.
|
|
22817
|
+
* Default: alert on terminal failure / timeout / missing handler, not on success.
|
|
22818
|
+
*/
|
|
22819
|
+
notify: external_exports.object({
|
|
22820
|
+
/** Default true. */
|
|
22821
|
+
onFailure: external_exports.boolean().optional(),
|
|
22822
|
+
/** Default false. */
|
|
22823
|
+
onSuccess: external_exports.boolean().optional(),
|
|
22824
|
+
/** Default 'critical' on failure. */
|
|
22825
|
+
severity: external_exports.enum(["info", "warning", "critical"]).optional()
|
|
22826
|
+
}).optional(),
|
|
22784
22827
|
/**
|
|
22785
22828
|
* Lot 4 — Optional input schema for the two triggers whose payload is caller-
|
|
22786
22829
|
* controlled rather than platform-shaped: `uiInvoke` (a browser session) and
|
|
@@ -22807,6 +22850,13 @@ var FunctionDefSchema = FunctionDefFieldsSchema.superRefine((fn, ctx) => {
|
|
|
22807
22850
|
message: `"input" is only allowed on uiInvoke and httpRoute triggers, not "${fn.trigger.type}"`
|
|
22808
22851
|
});
|
|
22809
22852
|
}
|
|
22853
|
+
if (fn.trigger.type === "httpRoute" && fn.trigger.isAuthRequired === false && fn.trigger.minRole !== void 0) {
|
|
22854
|
+
ctx.addIssue({
|
|
22855
|
+
code: "custom",
|
|
22856
|
+
path: ["trigger", "minRole"],
|
|
22857
|
+
message: '"minRole" is meaningless on an unauthenticated webhook route (isAuthRequired: false)'
|
|
22858
|
+
});
|
|
22859
|
+
}
|
|
22810
22860
|
});
|
|
22811
22861
|
var AppRoleSchema = external_exports.object({
|
|
22812
22862
|
reads: external_exports.array(external_exports.string()),
|
|
@@ -22823,8 +22873,20 @@ var AppRoleSchema = external_exports.object({
|
|
|
22823
22873
|
* Absence means the capability is denied (deny-by-default, backward-compatible).
|
|
22824
22874
|
* P2 approvals will reuse this field.
|
|
22825
22875
|
*/
|
|
22826
|
-
capabilities: external_exports.array(external_exports.string()).optional()
|
|
22876
|
+
capabilities: external_exports.array(external_exports.string()).optional(),
|
|
22877
|
+
/**
|
|
22878
|
+
* Cross-app function calls this app INTENDS to make, as `app:<slug>/<functionName>`
|
|
22879
|
+
* refs. Declaring a ref here grants nothing by itself — it only becomes a real
|
|
22880
|
+
* capability when the target function's `uiInvoke` trigger lists this app (or
|
|
22881
|
+
* `'*'`) in its own `exposedToApps`. Same asymmetry as `dbEvent` subscriptions
|
|
22882
|
+
* (P2-10): the caller's self-declaration is necessary but never sufficient.
|
|
22883
|
+
*
|
|
22884
|
+
* Unlike `reads`/`writes`, entries here are EXPECTED to name a foreign app —
|
|
22885
|
+
* `findForeignRoleRefs` does not (and must not) inspect this field.
|
|
22886
|
+
*/
|
|
22887
|
+
calls: external_exports.array(external_exports.string()).optional()
|
|
22827
22888
|
});
|
|
22889
|
+
var UI_ENTRY_REGEX = /^dist\/ui\/[A-Za-z0-9_-]+\.js$/;
|
|
22828
22890
|
var PageDefSchema = external_exports.object({
|
|
22829
22891
|
universalIdentifier: external_exports.string().uuid(),
|
|
22830
22892
|
path: external_exports.string().regex(
|
|
@@ -22833,8 +22895,10 @@ var PageDefSchema = external_exports.object({
|
|
|
22833
22895
|
),
|
|
22834
22896
|
title: external_exports.string(),
|
|
22835
22897
|
icon: external_exports.string().optional(),
|
|
22836
|
-
|
|
22837
|
-
//
|
|
22898
|
+
// Relative path inside the tarball, e.g. 'dist/ui/attribution.js'. The CLI
|
|
22899
|
+
// always emits 'dist/ui/<path>.js' for a page — see UI_ENTRY_REGEX above for
|
|
22900
|
+
// why only the shape (not the path/entry cross-check) is enforced here.
|
|
22901
|
+
entry: external_exports.string().regex(UI_ENTRY_REGEX, "page entry must be a 'dist/ui/<name>.js' path")
|
|
22838
22902
|
});
|
|
22839
22903
|
var SettingsFieldSchema = external_exports.object({
|
|
22840
22904
|
key: external_exports.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/, "settings key must be a valid identifier"),
|
|
@@ -22849,11 +22913,10 @@ var SettingsFieldSchema = external_exports.object({
|
|
|
22849
22913
|
var AppSettingsSchema = external_exports.object({
|
|
22850
22914
|
fields: external_exports.array(SettingsFieldSchema)
|
|
22851
22915
|
});
|
|
22852
|
-
var SETTINGS_ENTRY_REGEX = /^dist\/ui\/[A-Za-z0-9_-]+\.js$/;
|
|
22853
22916
|
var SettingsPageSchema = external_exports.object({
|
|
22854
22917
|
universalIdentifier: external_exports.string().uuid(),
|
|
22855
22918
|
/** Relative path inside the tarball, e.g. 'dist/ui/settings.js'. */
|
|
22856
|
-
entry: external_exports.string().regex(
|
|
22919
|
+
entry: external_exports.string().regex(UI_ENTRY_REGEX, "settingsPage entry must be a 'dist/ui/<name>.js' path"),
|
|
22857
22920
|
/** Page heading; defaults to "Paramètres" in the shell. */
|
|
22858
22921
|
title: external_exports.string().optional()
|
|
22859
22922
|
});
|
|
@@ -22881,8 +22944,12 @@ var AppManifestFieldsSchema = external_exports.object({
|
|
|
22881
22944
|
// true for spaces with no views yet
|
|
22882
22945
|
reads: external_exports.array(external_exports.string()),
|
|
22883
22946
|
// core objects read: ['order']
|
|
22884
|
-
|
|
22885
|
-
|
|
22947
|
+
// 0.9.0 breaking change (D28): `hooks` (`preInstall`/`postInstall`) removed —
|
|
22948
|
+
// the feature was undocumented, declared by zero manifest in the repo, and
|
|
22949
|
+
// made install fail whenever it was used (HookRunnerService.run sent an event
|
|
22950
|
+
// no Inngest function ever subscribed to). Because this object is not
|
|
22951
|
+
// `.strict()`, a stored manifest that still carries `hooks` keeps parsing —
|
|
22952
|
+
// the key is simply ignored. No data migration, no pre-flight required.
|
|
22886
22953
|
serverVariables: external_exports.array(ServerVariableSchema).optional(),
|
|
22887
22954
|
pages: external_exports.array(PageDefSchema).optional(),
|
|
22888
22955
|
// #71: React UI pages bundled in the artifact
|
|
@@ -22907,7 +22974,26 @@ var AppManifestFieldsSchema = external_exports.object({
|
|
|
22907
22974
|
icon: external_exports.string().optional(),
|
|
22908
22975
|
coreRef: external_exports.string().optional(),
|
|
22909
22976
|
fields: external_exports.array(FieldDefSchema),
|
|
22910
|
-
indexes: external_exports.array(IndexDefSchema).max(10).optional()
|
|
22977
|
+
indexes: external_exports.array(IndexDefSchema).max(10).optional(),
|
|
22978
|
+
/**
|
|
22979
|
+
* P2-10 — bilateral consent for cross-app access to this object. ONE
|
|
22980
|
+
* meaning: "this app may observe and read this object" — it governs
|
|
22981
|
+
* every capability built on it, not just its original one:
|
|
22982
|
+
* - a `dbEvent` subscription, via a trigger whose `objectRef` names
|
|
22983
|
+
* it (`app:<this app's slug>/<objectKey>`);
|
|
22984
|
+
* - a direct cross-app record/aggregate READ with another app's
|
|
22985
|
+
* token (`PlatformDataAuthGuard`) — writes are never granted this
|
|
22986
|
+
* way, consent or not.
|
|
22987
|
+
* Entries are `app:<slug>` for one named app, or the wildcard `'*'`
|
|
22988
|
+
* for any installed app.
|
|
22989
|
+
*
|
|
22990
|
+
* A caller's own manifest or request naming this object grants it
|
|
22991
|
+
* nothing by itself — only this list does. See `isObjectExposedTo`.
|
|
22992
|
+
*
|
|
22993
|
+
* Optional and additive: an existing manifest without this field keeps
|
|
22994
|
+
* parsing unchanged, and is treated as exposing the object to no one.
|
|
22995
|
+
*/
|
|
22996
|
+
exposedToApps: external_exports.array(external_exports.string()).optional()
|
|
22911
22997
|
})
|
|
22912
22998
|
),
|
|
22913
22999
|
actions: external_exports.array(external_exports.object({ provider: external_exports.string(), action: external_exports.string() })),
|
|
@@ -23005,6 +23091,23 @@ var coreOrder = {
|
|
|
23005
23091
|
requiredRole: "VIEWER"
|
|
23006
23092
|
};
|
|
23007
23093
|
var CORE_OBJECTS = /* @__PURE__ */ new Map([[coreOrder.key, coreOrder]]);
|
|
23094
|
+
function checkManifestSemantics(manifest) {
|
|
23095
|
+
const errors = [];
|
|
23096
|
+
const emits = manifest.emits ?? [];
|
|
23097
|
+
for (const fn of manifest.functions ?? []) {
|
|
23098
|
+
if (fn.retries !== void 0 && fn.retries > MAX_FUNCTION_RETRIES) {
|
|
23099
|
+
errors.push(
|
|
23100
|
+
`functions."${fn.name}".retries: ${fn.retries} exceeds the platform maximum of ${MAX_FUNCTION_RETRIES}. Inngest refuses a function configured above ${MAX_FUNCTION_RETRIES} retries, so this app's functions would fail to register.`
|
|
23101
|
+
);
|
|
23102
|
+
}
|
|
23103
|
+
if (fn.onFailure !== void 0 && !emits.includes(fn.onFailure)) {
|
|
23104
|
+
errors.push(
|
|
23105
|
+
`functions."${fn.name}".onFailure: "${fn.onFailure}" is not declared in manifest.emits. onFailure travels on the app custom-event bus; naming an integration or platform event would re-invoke that handler with a failure payload.`
|
|
23106
|
+
);
|
|
23107
|
+
}
|
|
23108
|
+
}
|
|
23109
|
+
return errors;
|
|
23110
|
+
}
|
|
23008
23111
|
|
|
23009
23112
|
// src/manifest-build.ts
|
|
23010
23113
|
var ManifestBuildError = class extends Error {
|
|
@@ -23052,6 +23155,13 @@ Ensure the file exists and exports a default AppManifest.`
|
|
|
23052
23155
|
const diagnostic = parsed.error.issues.map((i) => ` ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
23053
23156
|
throw new ManifestBuildError("Manifest validation failed", diagnostic);
|
|
23054
23157
|
}
|
|
23158
|
+
const semanticErrors = checkManifestSemantics(parsed.data);
|
|
23159
|
+
if (semanticErrors.length > 0) {
|
|
23160
|
+
throw new ManifestBuildError(
|
|
23161
|
+
"Manifest validation failed",
|
|
23162
|
+
semanticErrors.map((e) => ` ${e}`).join("\n")
|
|
23163
|
+
);
|
|
23164
|
+
}
|
|
23055
23165
|
return parsed.data;
|
|
23056
23166
|
} catch (err) {
|
|
23057
23167
|
if (err instanceof ManifestBuildError) throw err;
|
|
@@ -23089,8 +23199,7 @@ async function buildApp(projectRoot, tarball) {
|
|
|
23089
23199
|
(0, import_fs4.writeFileSync)(manifestPath, JSON.stringify(stamped, null, 2), "utf8");
|
|
23090
23200
|
(0, import_fs4.writeFileSync)(checksumPath, checksum2, "utf8");
|
|
23091
23201
|
const tgzFiles = {
|
|
23092
|
-
"manifest.json": stamped
|
|
23093
|
-
checksum: checksum2
|
|
23202
|
+
"manifest.json": stamped
|
|
23094
23203
|
};
|
|
23095
23204
|
if (bundleBuffer) {
|
|
23096
23205
|
tgzFiles["dist/index.js"] = bundleBuffer;
|