@proveanything/smartlinks 2.0.39 → 2.0.41
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/interactions.d.ts +14 -1
- package/dist/api/interactions.js +27 -0
- package/dist/docs/API_SUMMARY.md +46 -9
- package/dist/docs/iframe-responder.md +310 -308
- package/dist/docs/interactions.md +65 -55
- package/dist/docs/overview.md +1 -1
- package/dist/docs/server-functions.md +34 -0
- package/dist/http.d.ts +5 -0
- package/dist/http.js +28 -4
- package/dist/openapi.yaml +49 -1
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +1 -0
- package/dist/types/appManifest.d.ts +31 -0
- package/dist/types/interaction.d.ts +16 -1
- package/docs/API_SUMMARY.md +46 -9
- package/docs/iframe-responder.md +310 -308
- package/docs/interactions.md +65 -55
- package/docs/overview.md +1 -1
- package/docs/server-functions.md +34 -0
- package/openapi.yaml +49 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminInteractionsCountsByOutcomeRequest, AdminInteractionsQueryRequest, AdminInteractionsAggregateRequest, AdminInteractionsAggregateResponse, AppendInteractionBody, UpdateInteractionBody, OutcomeCount, InteractionEventRow, PublicInteractionsCountsByOutcomeRequest, PublicInteractionsByUserRequest, SubmitInteractionResponse, SubmitInteractionError, CreateInteractionTypeBody, UpdateInteractionTypeBody, ListInteractionTypesQuery, InteractionTypeRecord, InteractionTypeList } from "../types/interaction.js";
|
|
1
|
+
import type { AdminInteractionsCountsByOutcomeRequest, AdminInteractionsQueryRequest, AdminInteractionsAggregateRequest, AdminInteractionsAggregateResponse, AppendInteractionBody, UpdateInteractionBody, OutcomeCount, InteractionEventRow, PublicInteractionsCountsByOutcomeRequest, PublicInteractionsByUserRequest, SubmitInteractionResponse, SubmitInteractionError, CreateInteractionTypeBody, EnsureInteractionTypeInput, UpdateInteractionTypeBody, ListInteractionTypesQuery, InteractionTypeRecord, InteractionTypeList } from "../types/interaction.js";
|
|
2
2
|
export declare namespace interactions {
|
|
3
3
|
/**
|
|
4
4
|
* POST /admin/collection/:collectionId/interactions/query
|
|
@@ -45,6 +45,19 @@ export declare namespace interactions {
|
|
|
45
45
|
function submitPublicEvent(collectionId: string, body: AppendInteractionBody): Promise<SubmitInteractionResponse | SubmitInteractionError>;
|
|
46
46
|
function create(collectionId: string, body: CreateInteractionTypeBody): Promise<InteractionTypeRecord>;
|
|
47
47
|
function list(collectionId: string, query?: ListInteractionTypesQuery): Promise<InteractionTypeList>;
|
|
48
|
+
/**
|
|
49
|
+
* Find this app's interaction type by its readable `key` (data.interactionType), or create it.
|
|
50
|
+
* Returns the type record — its `id` is the server-minted UUID every event must use.
|
|
51
|
+
* ADMIN only (run it in your admin/setup screen), then store the id in your app config so
|
|
52
|
+
* public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const vote = await SL.interactions.ensureType(collectionId, {
|
|
56
|
+
* appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true },
|
|
57
|
+
* })
|
|
58
|
+
* // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
59
|
+
*/
|
|
60
|
+
function ensureType(collectionId: string, input: EnsureInteractionTypeInput): Promise<InteractionTypeRecord>;
|
|
48
61
|
function get(collectionId: string, id: string): Promise<InteractionTypeRecord>;
|
|
49
62
|
function update(collectionId: string, id: string, patchBody: UpdateInteractionTypeBody): Promise<InteractionTypeRecord>;
|
|
50
63
|
function remove(collectionId: string, id: string): Promise<void>;
|
package/dist/api/interactions.js
CHANGED
|
@@ -102,6 +102,33 @@ export var interactions;
|
|
|
102
102
|
return request(path);
|
|
103
103
|
}
|
|
104
104
|
interactions.list = list;
|
|
105
|
+
/**
|
|
106
|
+
* Find this app's interaction type by its readable `key` (data.interactionType), or create it.
|
|
107
|
+
* Returns the type record — its `id` is the server-minted UUID every event must use.
|
|
108
|
+
* ADMIN only (run it in your admin/setup screen), then store the id in your app config so
|
|
109
|
+
* public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* const vote = await SL.interactions.ensureType(collectionId, {
|
|
113
|
+
* appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true },
|
|
114
|
+
* })
|
|
115
|
+
* // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
116
|
+
*/
|
|
117
|
+
async function ensureType(collectionId, input) {
|
|
118
|
+
const { appId, key, permissions, display, data } = input;
|
|
119
|
+
if (!appId || !key)
|
|
120
|
+
throw new Error('interactions.ensureType: appId and key are required');
|
|
121
|
+
for (let offset = 0;; offset += 200) {
|
|
122
|
+
const page = await list(collectionId, { appId, limit: 200, offset });
|
|
123
|
+
const found = (page.items || []).find((t) => t.data && t.data.interactionType === key);
|
|
124
|
+
if (found)
|
|
125
|
+
return found;
|
|
126
|
+
if (!page.items || page.items.length < 200)
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
return create(collectionId, Object.assign(Object.assign({ appId }, (permissions ? { permissions } : {})), { data: Object.assign(Object.assign(Object.assign({}, (data || {})), { interactionType: key }), (display ? { display } : {})) }));
|
|
130
|
+
}
|
|
131
|
+
interactions.ensureType = ensureType;
|
|
105
132
|
async function get(collectionId, id) {
|
|
106
133
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/${encodeURIComponent(id)}`;
|
|
107
134
|
return request(path);
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.41 | Generated: 2026-10-06T07:00:42.791Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -2539,6 +2539,7 @@ interface AppFunctionDef {
|
|
|
2539
2539
|
elevated?: boolean;
|
|
2540
2540
|
capabilities?: string[];
|
|
2541
2541
|
dataScope?: 'collection' | 'global';
|
|
2542
|
+
inputs?: AppFunctionInputs;
|
|
2542
2543
|
apiVersion?: string;
|
|
2543
2544
|
handler?: string;
|
|
2544
2545
|
agent?: AppFunctionAgentExposure;
|
|
@@ -2622,6 +2623,27 @@ interface ServerFunctionContext {
|
|
|
2622
2623
|
caller: ServerFunctionCaller;
|
|
2623
2624
|
fetch: typeof fetch;
|
|
2624
2625
|
log: (message: string, data?: Record<string, any>) => void;
|
|
2626
|
+
inputs: Readonly<ServerFunctionInputs>;
|
|
2627
|
+
}
|
|
2628
|
+
```
|
|
2629
|
+
|
|
2630
|
+
**AppFunctionInputs** (interface)
|
|
2631
|
+
```typescript
|
|
2632
|
+
interface AppFunctionInputs {
|
|
2633
|
+
entity?: boolean;
|
|
2634
|
+
collection?: boolean;
|
|
2635
|
+
appConfig?: boolean;
|
|
2636
|
+
product?: { from: `body.${string}` | `query.${string}` | 'path' };
|
|
2637
|
+
}
|
|
2638
|
+
```
|
|
2639
|
+
|
|
2640
|
+
**ServerFunctionInputs** (interface)
|
|
2641
|
+
```typescript
|
|
2642
|
+
interface ServerFunctionInputs {
|
|
2643
|
+
entity?: Record<string, any> | null;
|
|
2644
|
+
collection?: Record<string, any> | null;
|
|
2645
|
+
appConfig?: Record<string, any> | null;
|
|
2646
|
+
product?: Record<string, any> | null;
|
|
2625
2647
|
}
|
|
2626
2648
|
```
|
|
2627
2649
|
|
|
@@ -7275,13 +7297,24 @@ interface InteractionTypeList {
|
|
|
7275
7297
|
**CreateInteractionTypeBody** (interface)
|
|
7276
7298
|
```typescript
|
|
7277
7299
|
interface CreateInteractionTypeBody {
|
|
7278
|
-
id
|
|
7300
|
+
id?: string
|
|
7279
7301
|
appId: string
|
|
7280
7302
|
permissions?: InteractionPermissions
|
|
7281
7303
|
data?: Record<string, unknown>
|
|
7282
7304
|
}
|
|
7283
7305
|
```
|
|
7284
7306
|
|
|
7307
|
+
**EnsureInteractionTypeInput** (interface)
|
|
7308
|
+
```typescript
|
|
7309
|
+
interface EnsureInteractionTypeInput {
|
|
7310
|
+
appId: string
|
|
7311
|
+
key: string
|
|
7312
|
+
permissions?: InteractionPermissions
|
|
7313
|
+
display?: InteractionDisplay
|
|
7314
|
+
data?: Record<string, unknown>
|
|
7315
|
+
}
|
|
7316
|
+
```
|
|
7317
|
+
|
|
7285
7318
|
**UpdateInteractionTypeBody** (interface)
|
|
7286
7319
|
```typescript
|
|
7287
7320
|
interface UpdateInteractionTypeBody {
|
|
@@ -11325,36 +11358,40 @@ POST /api/v1/public/collection/:collectionId/interactions/submit Submits an inte
|
|
|
11325
11358
|
query: ListInteractionTypesQuery = {}) → `Promise<InteractionTypeList>`
|
|
11326
11359
|
POST /api/v1/public/collection/:collectionId/interactions/submit Submits an interaction event from a public/client-side context. `interactionId` must reference an existing interaction type definition. This endpoint does not create interaction definitions. When the interaction has `allowAnonymousSubmit: true`, neither `userId` nor `contactId` is required. Pass `anonId` inside `metadata` to enable device-level deduplication via `uniquePerAnonId`.
|
|
11327
11360
|
|
|
11361
|
+
**ensureType**(collectionId: string,
|
|
11362
|
+
input: EnsureInteractionTypeInput) → `Promise<InteractionTypeRecord>`
|
|
11363
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11364
|
+
|
|
11328
11365
|
**get**(collectionId: string,
|
|
11329
11366
|
id: string) → `Promise<InteractionTypeRecord>`
|
|
11330
|
-
|
|
11367
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11331
11368
|
|
|
11332
11369
|
**update**(collectionId: string,
|
|
11333
11370
|
id: string,
|
|
11334
11371
|
patchBody: UpdateInteractionTypeBody) → `Promise<InteractionTypeRecord>`
|
|
11335
|
-
|
|
11372
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11336
11373
|
|
|
11337
11374
|
**remove**(collectionId: string,
|
|
11338
11375
|
id: string) → `Promise<void>`
|
|
11339
|
-
|
|
11376
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11340
11377
|
|
|
11341
11378
|
**publicCountsByOutcome**(collectionId: string,
|
|
11342
11379
|
body: PublicInteractionsCountsByOutcomeRequest,
|
|
11343
11380
|
authToken?: string) → `Promise<OutcomeCount[]>`
|
|
11344
|
-
|
|
11381
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11345
11382
|
|
|
11346
11383
|
**publicMyInteractions**(collectionId: string,
|
|
11347
11384
|
body: PublicInteractionsByUserRequest,
|
|
11348
11385
|
authToken?: string) → `Promise<InteractionEventRow[]>`
|
|
11349
|
-
|
|
11386
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11350
11387
|
|
|
11351
11388
|
**publicList**(collectionId: string,
|
|
11352
11389
|
query: ListInteractionTypesQuery = {}) → `Promise<InteractionTypeList>`
|
|
11353
|
-
|
|
11390
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11354
11391
|
|
|
11355
11392
|
**publicGet**(collectionId: string,
|
|
11356
11393
|
id: string) → `Promise<InteractionTypeRecord>`
|
|
11357
|
-
|
|
11394
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
11358
11395
|
|
|
11359
11396
|
### jobs
|
|
11360
11397
|
|