@flowrunner/cli 0.1.14 → 0.1.15
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/ai-docs/instructions/service-code-format/04-http-requests.md +9 -0
- package/ai-docs/instructions/service-code-format/06-oauth2.md +59 -9
- package/ai-docs/instructions/service-code-format/07-actions.md +1 -1
- package/ai-docs/instructions/service-code-format/08-polling-triggers.md +13 -0
- package/ai-docs/instructions/service-code-format/09-realtime-triggers.md +110 -4
- package/ai-docs/instructions/service-code-format/16-gotchas.md +24 -0
- package/ai-docs/instructions/service-code-format/18-test-recipes.md +16 -0
- package/ai-docs/instructions/service-code-format/19-security.md +121 -0
- package/ai-docs/instructions/service-code-format/README.md +3 -2
- package/ai-docs/providers/claude/agents/flowrunner-service-code-engineer.md +1 -1
- package/dist/cli.js +48 -9
- package/dist/cli.js.map +2 -2
- package/dist/index.js +47 -8
- package/dist/index.js.map +2 -2
- package/dist/types/flow-extension-runner/src/v2/oauth/types.d.ts +9 -7
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +2 -1
- package/dist/types/shared/src/constants/activity-log.d.ts +77 -0
- package/dist/types/shared/src/constants/app.d.ts +0 -1
- package/dist/types/shared/src/constants/notification-types.d.ts +117 -6
- package/dist/types/shared/src/scheme/account/dto.d.ts +3 -0
- package/dist/types/shared/src/scheme/crm/dto.d.ts +6 -0
- package/dist/types/shared/src/scheme/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/integration-connection/dto.d.ts +27 -15
- package/dist/types/shared/src/scheme/notifications/dto.d.ts +3 -0
- package/dist/types/shared/src/scheme/notifications/rest.d.ts +6 -0
- package/dist/types/shared/src/scheme/onboarding/dto.d.ts +29 -0
- package/dist/types/shared/src/scheme/onboarding/index.d.ts +1 -0
- package/package.json +1 -1
- package/runtime/index.js +47 -8
- package/runtime/index.js.map +2 -2
- package/runtime/types/flow-extension-runner/src/v2/oauth/types.d.ts +9 -7
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +2 -1
- package/runtime/types/shared/src/constants/activity-log.d.ts +77 -0
- package/runtime/types/shared/src/constants/app.d.ts +0 -1
- package/runtime/types/shared/src/constants/notification-types.d.ts +117 -6
- package/runtime/types/shared/src/scheme/account/dto.d.ts +3 -0
- package/runtime/types/shared/src/scheme/crm/dto.d.ts +6 -0
- package/runtime/types/shared/src/scheme/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/integration-connection/dto.d.ts +27 -15
- package/runtime/types/shared/src/scheme/notifications/dto.d.ts +3 -0
- package/runtime/types/shared/src/scheme/notifications/rest.d.ts +6 -0
- package/runtime/types/shared/src/scheme/onboarding/dto.d.ts +29 -0
- package/runtime/types/shared/src/scheme/onboarding/index.d.ts +1 -0
package/runtime/index.js
CHANGED
|
@@ -14524,10 +14524,11 @@ var OAuth2 = class {
|
|
|
14524
14524
|
this.#registerSystemMethods();
|
|
14525
14525
|
}
|
|
14526
14526
|
// The handler bag's `oauth`: the header access token, plus its deserialized composite payload when the
|
|
14527
|
-
// author declared a deserializer (the pattern for providers whose "token" carries a realm or instance id)
|
|
14527
|
+
// author declared a deserializer (the pattern for providers whose "token" carries a realm or instance id),
|
|
14528
|
+
// and that payload's `userData` — the standard shape's slot for per-connection data.
|
|
14528
14529
|
buildBag(accessToken) {
|
|
14529
14530
|
const token = this.props.deserializeToken && accessToken != null ? this.props.deserializeToken(accessToken) : void 0;
|
|
14530
|
-
return { accessToken, token };
|
|
14531
|
+
return { accessToken, token, userData: userDataOf(token) };
|
|
14531
14532
|
}
|
|
14532
14533
|
// ── SYSTEM seam: name · input · return · handler, in one table ─────────────
|
|
14533
14534
|
#registerSystemMethods() {
|
|
@@ -14615,12 +14616,23 @@ var OAuth2 = class {
|
|
|
14615
14616
|
});
|
|
14616
14617
|
const nextRefresh = tokenResponse.refresh_token ?? currentRefreshToken;
|
|
14617
14618
|
return {
|
|
14618
|
-
token: this.#serialize(tokenResponse.access_token, nextRefresh),
|
|
14619
|
+
token: this.#serialize(tokenResponse.access_token, nextRefresh, this.#storedUserData(ctx)),
|
|
14619
14620
|
expirationInSeconds: tokenResponse.expires_in,
|
|
14620
14621
|
refreshToken: nextRefresh
|
|
14621
14622
|
};
|
|
14622
14623
|
}
|
|
14623
14624
|
// ── token exchange ─────────────────────────────────────────────────────────
|
|
14625
|
+
// A refresh response repeats none of the connect-time data, and the platform keeps the connection's
|
|
14626
|
+
// `userData` to itself, so the only copy is inside the current token: read it back, to store it again in
|
|
14627
|
+
// the next one. A token the deserializer cannot read — a bare one saved before the service wrapped its
|
|
14628
|
+
// tokens — has nothing to carry over, and must not fail the refresh for that.
|
|
14629
|
+
#storedUserData(ctx) {
|
|
14630
|
+
try {
|
|
14631
|
+
return ctx.oauth.userData;
|
|
14632
|
+
} catch {
|
|
14633
|
+
return void 0;
|
|
14634
|
+
}
|
|
14635
|
+
}
|
|
14624
14636
|
#serialize(accessToken, refreshToken, userData) {
|
|
14625
14637
|
return this.props.serializeToken ? this.props.serializeToken({ accessToken, refreshToken, userData }) : accessToken;
|
|
14626
14638
|
}
|
|
@@ -14645,6 +14657,9 @@ var OAuth2 = class {
|
|
|
14645
14657
|
return Flowrunner.Request.post(this.props.tokenUrl).set(headers).send(params.toString());
|
|
14646
14658
|
}
|
|
14647
14659
|
};
|
|
14660
|
+
function userDataOf(token) {
|
|
14661
|
+
return token && typeof token === "object" ? token.userData : void 0;
|
|
14662
|
+
}
|
|
14648
14663
|
|
|
14649
14664
|
// ../../flow-extension-runner/src/v2/polling-triggers/method-names.ts
|
|
14650
14665
|
var POLLING_SYSTEM_METHOD = "handleTriggerPollingForEvent";
|
|
@@ -14957,11 +14972,14 @@ var RealtimeSelectInvocationSchema = z.looseObject({
|
|
|
14957
14972
|
|
|
14958
14973
|
// ../../flow-extension-runner/src/v2/realtime-triggers/verify.ts
|
|
14959
14974
|
function verifyDeclarative(verify, rawBody, headers, config, webhookData) {
|
|
14975
|
+
const secret = verify.secret(config, { webhookData });
|
|
14976
|
+
if (!secret) {
|
|
14977
|
+
return true;
|
|
14978
|
+
}
|
|
14960
14979
|
const provided = headers[verify.header] ?? headers[verify.header.toLowerCase()];
|
|
14961
14980
|
if (!provided) {
|
|
14962
14981
|
return false;
|
|
14963
14982
|
}
|
|
14964
|
-
const secret = verify.secret(config, { webhookData });
|
|
14965
14983
|
const computed = Flowrunner.crypto.hmac(verify.algo, secret, rawBody ?? "", verify.encoding);
|
|
14966
14984
|
if (!Flowrunner.crypto.timingSafeEqual(provided, computed)) {
|
|
14967
14985
|
return false;
|
|
@@ -15038,12 +15056,32 @@ var RealtimeSetup = class {
|
|
|
15038
15056
|
webhookData: invocation.webhookData ?? null,
|
|
15039
15057
|
connectionId: invocation.connectionId
|
|
15040
15058
|
}));
|
|
15059
|
+
this.#warnOnSuspectScope(result?.eventScopeId, ctx);
|
|
15041
15060
|
return {
|
|
15042
15061
|
webhookData: result?.webhookData,
|
|
15043
15062
|
eventScopeId: result?.eventScopeId,
|
|
15044
15063
|
refreshIntervalInSeconds: result?.refreshIntervalInSeconds
|
|
15045
15064
|
};
|
|
15046
15065
|
}
|
|
15066
|
+
// On ALL_APPS the platform routes every delivery of the shared callback by `eventScopeId`, so it has to name
|
|
15067
|
+
// the customer's tenant. A missing one leaves the app unroutable; the extension's own id or name is the
|
|
15068
|
+
// constant an author most often reaches for, and it puts every customer on one routing key. Neither is
|
|
15069
|
+
// refused — a warning, because a value equal to the name could in principle be a real tenant id.
|
|
15070
|
+
#warnOnSuspectScope(eventScopeId, ctx) {
|
|
15071
|
+
if (this.props.scope !== "ALL_APPS") {
|
|
15072
|
+
return;
|
|
15073
|
+
}
|
|
15074
|
+
const { id, name } = this.extension.props;
|
|
15075
|
+
if (eventScopeId == null || eventScopeId === "") {
|
|
15076
|
+
ctx.logger.warn(
|
|
15077
|
+
`[flow-extension:${id}] ALL_APPS subscribe returned no eventScopeId \u2014 deliveries on the shared callback cannot be routed to this app`
|
|
15078
|
+
);
|
|
15079
|
+
} else if (eventScopeId === id || eventScopeId === name) {
|
|
15080
|
+
ctx.logger.warn(
|
|
15081
|
+
`[flow-extension:${id}] ALL_APPS subscribe returned the extension's own ${eventScopeId === id ? "id" : "name"} ("${eventScopeId}") as eventScopeId \u2014 a constant puts every customer on one routing key; return the tenant id the provider's deliveries carry`
|
|
15082
|
+
);
|
|
15083
|
+
}
|
|
15084
|
+
}
|
|
15047
15085
|
async #unsubscribe(invocation, ctx) {
|
|
15048
15086
|
const result = await this.props.unsubscribe(ctx.bagWith({
|
|
15049
15087
|
callbackUrl: invocation.callbackUrl,
|
|
@@ -15104,8 +15142,9 @@ var RealtimeSetup = class {
|
|
|
15104
15142
|
const headers = invocation.headers ?? {};
|
|
15105
15143
|
const body = invocation.body;
|
|
15106
15144
|
const rawBody = invocation.rawBody;
|
|
15145
|
+
const query = invocation.queryParams ?? {};
|
|
15107
15146
|
const webhookData = invocation.webhookData ?? null;
|
|
15108
|
-
const handshake = await this.#handshake(body, headers, rawBody, webhookData, ctx);
|
|
15147
|
+
const handshake = await this.#handshake(body, headers, query, rawBody, webhookData, ctx);
|
|
15109
15148
|
if (handshake) {
|
|
15110
15149
|
return handshake;
|
|
15111
15150
|
}
|
|
@@ -15117,7 +15156,7 @@ var RealtimeSetup = class {
|
|
|
15117
15156
|
const result = await this.props.resolveEvents(ctx.bagWith({
|
|
15118
15157
|
rawBody,
|
|
15119
15158
|
headers,
|
|
15120
|
-
query
|
|
15159
|
+
query,
|
|
15121
15160
|
body,
|
|
15122
15161
|
webhookData,
|
|
15123
15162
|
connectionId: invocation.connectionId
|
|
@@ -15166,13 +15205,13 @@ var RealtimeSetup = class {
|
|
|
15166
15205
|
* pod as a failed invocation and the provider receives a 500 telling it nothing. The hook runs BEFORE
|
|
15167
15206
|
* verification, so the message reaches an unverified caller — throw what the provider may read.
|
|
15168
15207
|
*/
|
|
15169
|
-
async #handshake(body, headers, rawBody, webhookData, ctx) {
|
|
15208
|
+
async #handshake(body, headers, query, rawBody, webhookData, ctx) {
|
|
15170
15209
|
if (!this.props.handshake) {
|
|
15171
15210
|
return isEmptyBody(body) ? { handshake: true, events: [] } : null;
|
|
15172
15211
|
}
|
|
15173
15212
|
let result;
|
|
15174
15213
|
try {
|
|
15175
|
-
result = await this.props.handshake(ctx.bagWith({ requestBody: body, headers, rawBody, webhookData }));
|
|
15214
|
+
result = await this.props.handshake(ctx.bagWith({ requestBody: body, headers, query, rawBody, webhookData }));
|
|
15176
15215
|
} catch (error) {
|
|
15177
15216
|
const message = error?.message ?? String(error);
|
|
15178
15217
|
ctx.logger.error(`[flow-extension:${this.extension.id}] handshake failed \u2014 ${message}`);
|