@proveanything/smartlinks 2.0.40 → 2.0.42

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.
@@ -1,8 +1,28 @@
1
1
  import type { SecretMeta, SecretList, SetSecretInput, SetSecretResult, ListSecretsQuery } from "../types/integrations.js";
2
+ export interface AppSecretOptions {
3
+ /** The app whose secret this is. Defaults to the SDK's app context (`initializeApi({ appId })`). */
4
+ appId?: string;
5
+ }
2
6
  export declare namespace secrets {
7
+ /**
8
+ * Save this app's secret `name` on the collection (create or replace) — what the app's server
9
+ * functions read with `ctx.secrets.get(name)` (declare `secrets:<name>` in the manifest). Call it
10
+ * from your admin screen as a collection admin. Write-only: returns `{ ref: name, hint }`, never
11
+ * the value. PUT /app/:appId/secrets/:name
12
+ */
13
+ function put(collectionId: string, name: string, value: string, opts?: AppSecretOptions): Promise<SetSecretResult>;
14
+ /** This app's secrets on the collection: names + masked hints (never values). GET /app/:appId/secrets */
15
+ function listOwn(collectionId: string, opts?: AppSecretOptions): Promise<SecretList>;
16
+ /** Delete this app's secret `name`. DELETE /app/:appId/secrets/:name */
17
+ function removeOwn(collectionId: string, name: string, opts?: AppSecretOptions): Promise<{
18
+ deleted: boolean;
19
+ }>;
3
20
  /** List secrets as refs + masked hints + metadata (never values). GET /secrets */
4
21
  function list(collectionId: string, query?: ListSecretsQuery): Promise<SecretList>;
5
- /** Create a secret. POST /secrets → { ref, hint }. Store the ref on a flow. */
22
+ /**
23
+ * Create a collection secret with a GENERATED ref. POST /secrets → { ref, hint }. Store the ref on a
24
+ * flow. For a secret your app's server functions read by name, use `put` instead.
25
+ */
6
26
  function set(collectionId: string, input: SetSecretInput): Promise<SetSecretResult>;
7
27
  /** Metadata for one secret (never the value). GET /secrets/:ref */
8
28
  function get(collectionId: string, ref: string): Promise<SecretMeta>;
@@ -5,11 +5,15 @@
5
5
  // (refs + masked hints + metadata) and delete, but a value NEVER comes back over the
6
6
  // API. It is sealed at rest and resolved server-side only, at execution time.
7
7
  //
8
- // Typical use: `set` a credential, take the returned `ref`, and put it on a flow's
9
- // config.connection.auth.credentialRef.
8
+ // Two kinds:
9
+ // - an APP's own secret (`put` / `listOwn` / `removeOwn`): saved by name from the app's admin
10
+ // screen, read by that app's server functions with ctx.secrets.get('<name>'). Another app's
11
+ // secret of the same name is a different secret.
12
+ // - a collection secret (`set` / `rotate` / ...): `set` returns a generated `ref` to put on an
13
+ // integration flow's config.connection.auth.credentialRef.
10
14
  //
11
- // Endpoints: /admin/collection/:collectionId/secrets
12
- import { request, post, put, del } from "../http.js";
15
+ // Endpoints: /admin/collection/:collectionId/app/:appId/secrets, /admin/collection/:collectionId/secrets
16
+ import { request, post, put as put_, del, getAppContext } from "../http.js";
13
17
  function enc(v) { return encodeURIComponent(v); }
14
18
  function encodeQuery(params = {}) {
15
19
  const search = new URLSearchParams();
@@ -24,12 +28,42 @@ function encodeQuery(params = {}) {
24
28
  export var secrets;
25
29
  (function (secrets) {
26
30
  const base = (collectionId) => `/admin/collection/${enc(collectionId)}/secrets`;
31
+ const appBase = (collectionId, opts) => {
32
+ var _a;
33
+ const app = (_a = opts.appId) !== null && _a !== void 0 ? _a : getAppContext();
34
+ if (!app)
35
+ throw new Error("secrets: no app — pass { appId } or initializeApi({ appId })");
36
+ return `/admin/collection/${enc(collectionId)}/app/${enc(app)}/secrets`;
37
+ };
38
+ /**
39
+ * Save this app's secret `name` on the collection (create or replace) — what the app's server
40
+ * functions read with `ctx.secrets.get(name)` (declare `secrets:<name>` in the manifest). Call it
41
+ * from your admin screen as a collection admin. Write-only: returns `{ ref: name, hint }`, never
42
+ * the value. PUT /app/:appId/secrets/:name
43
+ */
44
+ async function put(collectionId, name, value, opts = {}) {
45
+ return put_(`${appBase(collectionId, opts)}/${enc(name)}`, { value });
46
+ }
47
+ secrets.put = put;
48
+ /** This app's secrets on the collection: names + masked hints (never values). GET /app/:appId/secrets */
49
+ async function listOwn(collectionId, opts = {}) {
50
+ return request(appBase(collectionId, opts));
51
+ }
52
+ secrets.listOwn = listOwn;
53
+ /** Delete this app's secret `name`. DELETE /app/:appId/secrets/:name */
54
+ async function removeOwn(collectionId, name, opts = {}) {
55
+ return del(`${appBase(collectionId, opts)}/${enc(name)}`);
56
+ }
57
+ secrets.removeOwn = removeOwn;
27
58
  /** List secrets as refs + masked hints + metadata (never values). GET /secrets */
28
59
  async function list(collectionId, query = {}) {
29
60
  return request(`${base(collectionId)}${encodeQuery(query)}`);
30
61
  }
31
62
  secrets.list = list;
32
- /** Create a secret. POST /secrets → { ref, hint }. Store the ref on a flow. */
63
+ /**
64
+ * Create a collection secret with a GENERATED ref. POST /secrets → { ref, hint }. Store the ref on a
65
+ * flow. For a secret your app's server functions read by name, use `put` instead.
66
+ */
33
67
  async function set(collectionId, input) {
34
68
  return post(base(collectionId), input);
35
69
  }
@@ -41,7 +75,7 @@ export var secrets;
41
75
  secrets.get = get;
42
76
  /** Rotate/update a secret's value (and optionally name/purpose). PUT /secrets/:ref → { ref, hint } */
43
77
  async function rotate(collectionId, ref, input) {
44
- return put(`${base(collectionId)}/${enc(ref)}`, input);
78
+ return put_(`${base(collectionId)}/${enc(ref)}`, input);
45
79
  }
46
80
  secrets.rotate = rotate;
47
81
  /** Soft-delete a secret. DELETE /secrets/:ref */
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.0.40 | Generated: 2026-10-05T14:51:09.158Z
3
+ Version: 2.0.42 | Generated: 2026-10-06T15:17:04.562Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -2523,6 +2523,7 @@ interface AppFunctionTrigger {
2523
2523
  type: AppFunctionTriggerType;
2524
2524
  eventTypes?: string[];
2525
2525
  schedule?: string;
2526
+ timezone?: string;
2526
2527
  route?: string;
2527
2528
  methods?: Array<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'>;
2528
2529
  }
@@ -2539,6 +2540,7 @@ interface AppFunctionDef {
2539
2540
  elevated?: boolean;
2540
2541
  capabilities?: string[];
2541
2542
  dataScope?: 'collection' | 'global';
2543
+ inputs?: AppFunctionInputs;
2542
2544
  apiVersion?: string;
2543
2545
  handler?: string;
2544
2546
  agent?: AppFunctionAgentExposure;
@@ -2622,6 +2624,27 @@ interface ServerFunctionContext {
2622
2624
  caller: ServerFunctionCaller;
2623
2625
  fetch: typeof fetch;
2624
2626
  log: (message: string, data?: Record<string, any>) => void;
2627
+ inputs: Readonly<ServerFunctionInputs>;
2628
+ }
2629
+ ```
2630
+
2631
+ **AppFunctionInputs** (interface)
2632
+ ```typescript
2633
+ interface AppFunctionInputs {
2634
+ entity?: boolean;
2635
+ collection?: boolean;
2636
+ appConfig?: boolean;
2637
+ product?: { from: `body.${string}` | `query.${string}` | 'path' };
2638
+ }
2639
+ ```
2640
+
2641
+ **ServerFunctionInputs** (interface)
2642
+ ```typescript
2643
+ interface ServerFunctionInputs {
2644
+ entity?: Record<string, any> | null;
2645
+ collection?: Record<string, any> | null;
2646
+ appConfig?: Record<string, any> | null;
2647
+ product?: Record<string, any> | null;
2625
2648
  }
2626
2649
  ```
2627
2650
 
@@ -9697,6 +9720,15 @@ interface FunctionSiteUrlOptions {
9697
9720
 
9698
9721
  **FunctionCallResult** = `any`
9699
9722
 
9723
+ ### secrets (api)
9724
+
9725
+ **AppSecretOptions** (interface)
9726
+ ```typescript
9727
+ interface AppSecretOptions {
9728
+ appId?: string
9729
+ }
9730
+ ```
9731
+
9700
9732
  ### sequence (api)
9701
9733
 
9702
9734
  **AllocateSequenceInput** (interface)
@@ -12026,11 +12058,20 @@ Fetch + extract a web page: clean markdown, page metadata, and any schema.org JS
12026
12058
 
12027
12059
  ### secrets
12028
12060
 
12061
+ **put**(collectionId: string, name: string, value: string, opts: AppSecretOptions = {}) → `Promise<SetSecretResult>`
12062
+ Save this app's secret `name` on the collection (create or replace) — what the app's server functions read with `ctx.secrets.get(name)` (declare `secrets:<name>` in the manifest). Call it from your admin screen as a collection admin. Write-only: returns `{ ref: name, hint }`, never the value. PUT /app/:appId/secrets/:name
12063
+
12064
+ **listOwn**(collectionId: string, opts: AppSecretOptions = {}) → `Promise<SecretList>`
12065
+ This app's secrets on the collection: names + masked hints (never values). GET /app/:appId/secrets
12066
+
12067
+ **removeOwn**(collectionId: string, name: string, opts: AppSecretOptions = {}) → `Promise<`
12068
+ Delete this app's secret `name`. DELETE /app/:appId/secrets/:name
12069
+
12029
12070
  **list**(collectionId: string, query: ListSecretsQuery = {}) → `Promise<SecretList>`
12030
12071
  List secrets as refs + masked hints + metadata (never values). GET /secrets
12031
12072
 
12032
12073
  **set**(collectionId: string, input: SetSecretInput) → `Promise<SetSecretResult>`
12033
- Create a secret. POST /secrets → { ref, hint }. Store the ref on a flow.
12074
+ Create a collection secret with a GENERATED ref. POST /secrets → { ref, hint }. Store the ref on a flow. For a secret your app's server functions read by name, use `put` instead.
12034
12075
 
12035
12076
  **get**(collectionId: string, ref: string) → `Promise<SecretMeta>`
12036
12077
  Metadata for one secret (never the value). GET /secrets/:ref