@alvera-ai/platform-sdk 0.10.0-rc.2 → 0.10.0-rc.21

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.
Files changed (55) hide show
  1. package/.agent/AGENTS.md +440 -0
  2. package/.agent/account_management.md +455 -0
  3. package/.agent/action_status_updaters.md +262 -0
  4. package/.agent/ai_agents.md +423 -0
  5. package/.agent/ai_sandbox.md +265 -0
  6. package/.agent/async.md +111 -0
  7. package/.agent/connected_apps.md +407 -0
  8. package/.agent/cookbook/_fixtures/README.md +99 -0
  9. package/.agent/cookbook/_fixtures/accounts_receivable/_customers_accounts_receivable_customer.liquid +32 -0
  10. package/.agent/cookbook/_fixtures/accounts_receivable/_customers_accounts_receivable_mdm.liquid +20 -0
  11. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_generic_table.liquid +33 -0
  12. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_legal_entity.liquid +88 -0
  13. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_mdm.liquid +48 -0
  14. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_appointment.liquid +47 -0
  15. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_mdm.liquid +24 -0
  16. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_patient.liquid +38 -0
  17. package/.agent/cookbook/_fixtures/payment_risk/_compliance_screenings_payment_risk_compliance_screening.liquid +59 -0
  18. package/.agent/cookbook/_fixtures/payment_risk/_compliance_screenings_payment_risk_mdm.liquid +36 -0
  19. package/.agent/cookbook/_fixtures/payment_risk/_payment_accounts_payment_risk_mdm.liquid +30 -0
  20. package/.agent/cookbook/_fixtures/payment_risk/_payment_accounts_payment_risk_payment_account.liquid +55 -0
  21. package/.agent/cookbook/_setup/accounts_receivable.md +282 -0
  22. package/.agent/cookbook/_setup/foundation.md +277 -0
  23. package/.agent/cookbook/_setup/healthcare.md +279 -0
  24. package/.agent/cookbook/_setup/payment_risk.md +283 -0
  25. package/.agent/cookbook/appointment-review-sms-workflow.md +761 -0
  26. package/.agent/cookbook/birthday-greeting-sms-trigger.md +656 -0
  27. package/.agent/cookbook/contact-us-triage-with-llm.md +603 -0
  28. package/.agent/cookbook/dunning-sms-for-delinquent.md +619 -0
  29. package/.agent/cookbook/kyc-notification-on-account-activation.md +619 -0
  30. package/.agent/cookbook/sanctions-screening-with-agent-review.md +711 -0
  31. package/.agent/cookbook/score-leads-with-llm-categorization.md +602 -0
  32. package/.agent/cookbook/welcome-sms-for-customers.md +607 -0
  33. package/.agent/data_activation_clients.md +557 -0
  34. package/.agent/data_sources.md +234 -0
  35. package/.agent/datalakes.md +712 -0
  36. package/.agent/debugging.md +137 -0
  37. package/.agent/errors.md +196 -0
  38. package/.agent/generic_tables.md +351 -0
  39. package/.agent/interoperability_contracts.md +351 -0
  40. package/.agent/mdm.md +293 -0
  41. package/.agent/mutations.md +152 -0
  42. package/.agent/templates.md +98 -0
  43. package/.agent/tool-call-configs.md +90 -0
  44. package/.agent/tools.md +546 -0
  45. package/.agent/type_naming.md +131 -0
  46. package/.agent/workflows.md +601 -0
  47. package/README.md +46 -0
  48. package/dist/bin/platform-sdk.d.mts +1 -0
  49. package/dist/bin/platform-sdk.mjs +106 -0
  50. package/dist/bin/platform-sdk.mjs.map +1 -0
  51. package/dist/index.d.mts +1200 -43201
  52. package/dist/index.d.mts.map +1 -1
  53. package/dist/index.mjs +1859 -7319
  54. package/dist/index.mjs.map +1 -1
  55. package/package.json +19 -10
@@ -0,0 +1,152 @@
1
+ # Mutations
2
+
3
+ The platform's CRUD verbs follow three uniform rules: POST
4
+ creates, PUT replays the full body on update, DELETE removes.
5
+ PATCH is reserved for limited surgical exceptions explicitly
6
+ called out below.
7
+
8
+ Non-CRUD methods on the SDK are out of scope for this page —
9
+ surgical RESTful sub-actions (`.syncRoutes`, `.resolvePage`,
10
+ `.testInvocation`), artifact issuers (`.createUploadLink`,
11
+ `.createDownloadLink`), and async action triggers (`.run`,
12
+ `.execute`) each have their own per-method semantics
13
+ documented in their resource's MD.
14
+
15
+ ## POST — create
16
+
17
+ `POST /<resource>` returns `201 Created` with the full
18
+ `<Resource>Response` body, including all server-derived
19
+ fields (`id`, `slug`, `status`, timestamps — see
20
+ `type_naming.md` "Server-derived fields"). Use this returned
21
+ body for any downstream references — never pre-compute
22
+ server-derived fields client-side.
23
+
24
+ ## PUT — full-body update
25
+
26
+ `PUT /<resource>/:slug` is a full-body replay, not a partial
27
+ update. To change a single field, submit the ENTIRE current
28
+ body with the changed field substituted in:
29
+
30
+ ```typescript
31
+ // 1. fetch current
32
+ const { data: current } = await api.tools.get(
33
+ tenantSlug, datalakeSlug, toolId,
34
+ )
35
+
36
+ // 2. mutate in memory
37
+ const next = { ...current, status: 'inactive' }
38
+
39
+ // 3. PUT the full mutated body
40
+ const { data: updated } = await api.tools.update(
41
+ tenantSlug, datalakeSlug, toolId, next,
42
+ )
43
+ ```
44
+
45
+ Omitting required fields on `PUT` triggers a 422 on those
46
+ fields, even when they're unchanged from the stored row — `PUT`
47
+ replaces the whole resource. The server returns the failure as a
48
+ 422 `AlveraApiError` (see `errors.md`).
49
+
50
+ ## PATCH exceptions (surgical partial-body updates)
51
+
52
+ A small set of update methods take a narrow partial body via
53
+ PATCH instead of the full-body PUT replay. Each is named here,
54
+ documents its partial-body contract in the TypeScript
55
+ wrapper's JSDoc, and is flagged in its per-resource MD §5
56
+ (Lifecycle):
57
+
58
+ | SDK method | Resource MD |
59
+ |---------------------------------------------|----------------------|
60
+ | `api.connectedApps.updateMessageTracking` | `connected_apps.md` |
61
+
62
+ For every other update method, the default rule applies:
63
+ PUT replays the full body.
64
+
65
+ > This is the canonical index of PATCH exceptions. If a
66
+ > future method joins, it lands here. If you encounter a
67
+ > method whose JSDoc claims partial-body behavior but it
68
+ > isn't listed here, this index is wrong and needs a
69
+ > refresh.
70
+
71
+ ## Discriminator on PUT must match
72
+
73
+ For polymorphic resources (tools, datalakes' cloud storage,
74
+ etc.), the body's discriminator value MUST match the
75
+ existing row's discriminator on update. The platform rejects
76
+ discriminator changes mid-life with a 422 on the
77
+ discriminator field's pointer.
78
+
79
+ Changing body type requires DELETE + recreate, not PUT.
80
+
81
+ ## Polymorphic discriminator naming
82
+
83
+ Resources with polymorphic body shapes use an explicit
84
+ discriminator field at the wire level. The discriminator's
85
+ **wire name** is what the SDK type expects; the
86
+ platform-internal struct name on the server side may differ.
87
+
88
+ Use the wire name everywhere:
89
+
90
+ | Resource | Discriminator (wire) |
91
+ |--------------------------------|--------------------------|
92
+ | Tool body | `tool_body_type` |
93
+ | Datalake cloud-storage embed | `cloud_storage_type` |
94
+
95
+ The wire name is what appears in your request body's JSON
96
+ and in `<Resource>RequestWritable` TypeScript types. Never
97
+ use the server-internal struct name (e.g. `__type__`) —
98
+ that's an implementation detail not surfaced to consumers.
99
+
100
+ Each resource's MD §1 (Wire shape) names its discriminator
101
+ and lists every branch's TypeScript type.
102
+
103
+ ## DELETE — usually synchronous
104
+
105
+ `DELETE /<resource>/:slug` removes the row. A few resources
106
+ have semantic guards (e.g. cannot delete a default-flagged
107
+ data activation client; cannot delete a datalake with
108
+ dependents) that surface as 422s with `source.pointer`
109
+ naming the field that's blocking the delete.
110
+
111
+ For asynchronous deletes (e.g. AWS Lambda tools' out-of-band
112
+ cleanup), poll the resource's status until it's gone — see
113
+ `async.md`.
114
+
115
+ ## URL path is authoritative over body for parent scopes
116
+
117
+ Every nested resource lives under a URL of the form:
118
+
119
+ ```
120
+ /api/v1/tenants/{tenant_slug}/datalakes/{datalake_slug}/<resource>[/{id}]
121
+ ```
122
+
123
+ The body usually carries a `datalake_id` (and sometimes
124
+ `tenant_id`) field naming the same parent. The platform
125
+ treats the **URL path as authoritative**: if the body
126
+ references a different parent than the URL names, the URL
127
+ wins and the body field is silently ignored. The row is
128
+ created under the URL's parent regardless of the body.
129
+
130
+ This holds for both POST and PUT, and across every nested
131
+ resource confirmed in tests so far (data sources, tools,
132
+ action status updaters, data activation clients, …). The
133
+ practical consequence:
134
+
135
+ - **Never use body fields to "redirect" a write to a
136
+ different datalake.** If you need to target a different
137
+ parent, change the URL.
138
+ - **Reusing a body across datalakes is safe.** A stored
139
+ `datalake_id` snapshot from a previous call can be sent
140
+ on a write under any URL — the URL governs where it lands.
141
+ - **422s on `/datalake_id` mismatch don't happen.** The
142
+ platform doesn't reject a body whose `datalake_id` differs
143
+ from the URL — it just ignores the body value.
144
+
145
+ ## No bulk mutations on standard CRUD
146
+
147
+ Each standard mutation request mutates ONE resource. The
148
+ platform doesn't accept batch creates or batch updates on
149
+ the standard CRUD endpoints. Some ingestion-side paths
150
+ (data-activation-client bulk runs, file uploads) ARE batch
151
+ by design — those are documented in the relevant resource's
152
+ MD.
@@ -0,0 +1,98 @@
1
+ # Templates
2
+
3
+ Templates are an **INFRASTRUCTURE** building block: the platform
4
+ ships a library of Liquid templates that other infrastructure
5
+ resources consume — interoperability contracts, AI agent prompts,
6
+ workflow definitions, status poller bodies. Templates are
7
+ **read-only** from the SDK; the platform composes them
8
+ per-industry, and each datalake's `data_domain` selects which
9
+ surface in its catalog.
10
+
11
+ SDK namespace: `api.templates`.
12
+
13
+ For the safety contract that bounds every template body the
14
+ platform accepts — the consumer-author trust boundary, the 11
15
+ custom Liquid filters, the SQL-fragment boundary, and the
16
+ compliance gates that compose with them — see `ai_sandbox.md`.
17
+
18
+ ## 1. Wire shape
19
+
20
+ Three discovery methods, two complementary response shapes —
21
+ structured (for code) and markdown (for agents):
22
+
23
+ ```typescript
24
+ import type { SystemTemplate } from '@alvera-ai/platform-sdk'
25
+
26
+ // Structured catalog
27
+ const { data: catalog } = await api.templates.systemTemplates(
28
+ tenantSlug,
29
+ datalakeSlug,
30
+ )
31
+ // catalog.data: SystemTemplate[]
32
+ // { path, content, output_schema }
33
+ // path category/sub-category/name segment string
34
+ // content Liquid template body
35
+ // output_schema null | object — rendered output's expected shape
36
+
37
+ // Markdown catalog
38
+ const { data: catalogMd } = await api.templates.metadata(
39
+ tenantSlug,
40
+ datalakeSlug,
41
+ )
42
+ // catalogMd: string — agent-facing markdown listing in-scope templates
43
+
44
+ // Markdown body for one template
45
+ const { data: templateMd } = await api.templates.metadataDetails(
46
+ tenantSlug,
47
+ datalakeSlug,
48
+ basename, // e.g. 'delivery_status' or 'contact_message_categorizer'
49
+ intent, // e.g. 'status_poller' or 'ai_agent' — note: intent
50
+ // != path segment;
51
+ // see §4 Gotcha 1
52
+ )
53
+ // templateMd: string — agent-facing markdown describing the template
54
+ ```
55
+
56
+ ## 2. Path structure
57
+
58
+ Template paths follow `<category>/<sub-category>/<name>`.
59
+ Categories the SDK exposes include
60
+ `data_activation/interoperability/`, `ai_agents/`, `workflows/`,
61
+ `status_poller/`. Categories with an industry segment (e.g.
62
+ `ai_agents/<industry>/*`) filter to the datalake's `data_domain`;
63
+ categories without (e.g. `status_poller/*/*`) are globals
64
+ present in every catalog.
65
+
66
+ ## 3. Lifecycle
67
+
68
+ Templates are static — they ship with the platform, not created
69
+ via SDK. New templates arrive via platform releases. If you need
70
+ a custom template, supply it inline (e.g. an interop contract's
71
+ `template_config: { type: 'custom', body: '...' }`) rather than
72
+ trying to add to the catalog.
73
+
74
+ ## 4. Gotchas
75
+
76
+ 1. **`basename` + `intent` is the composite key.** The `intent`
77
+ value is a fixed set of category identifiers — it does NOT
78
+ map cleanly to path segments. Some intents match (e.g.
79
+ `status_poller/...` → `'status_poller'`); some are
80
+ singularizations (e.g. `ai_agents/<industry>/<name>` →
81
+ `'ai_agent'`); some collapse multiple path segments (e.g.
82
+ `data_activation/interoperability/<industry>/...` →
83
+ `'data_activation_interoperability'`). Check the typed
84
+ parameter for the valid set; multiple templates can share a
85
+ basename across intents.
86
+
87
+ 2. **`output_schema` may be `null`.** Some templates render plain
88
+ strings without structured output. Test for null before
89
+ treating it as an object.
90
+
91
+ 3. **Templates from other industries never appear.** The
92
+ platform filters per-datalake. Walking the catalog gives only
93
+ in-scope entries; no need to filter by industry in your code.
94
+
95
+ 4. **Read-only from SDK.** For custom template content, use
96
+ inline `template_config` on the consuming resource (interop
97
+ contracts, AI agents, etc.) rather than seeking a catalog
98
+ addition.
@@ -0,0 +1,90 @@
1
+ <!-- alvera:doc kind="tool-call-configs" generated-by="mix alvera.dump.static_metadata" -->
2
+
3
+ # Tool Call Configurations
4
+
5
+ Per-invocation invocation-side schemas for Alvera tools. Each section
6
+ documents one variant of `Platform.Tools.ToolCallConfig`, identified
7
+ by its atom and rendered by `ToolCallConfig.metadata_details/2`.
8
+
9
+ <!-- alvera:section kind="tool-call-config" atom="restapi_request" module="Platform.Tools.ToolCallConfig.RESTAPIRequest" -->
10
+
11
+ ## Tool Call Configuration (restapi_request)
12
+
13
+ Fetches data via REST API with pagination support.
14
+
15
+ - **method** (enum: head, get, put, post, delete, patch) — HTTP method
16
+ - **path** (TemplateConfig) — API endpoint path, rendered as Liquid template
17
+ - **body** (TemplateConfig, nullable) — Request body, rendered as Liquid template
18
+ - **params** (TemplateConfig, nullable) — Query parameters, rendered as Liquid template
19
+ - **pagination_context_template** (TemplateConfig) — Pagination control template, must render to JSON with `has_next` boolean field
20
+
21
+ <!-- alvera:section kind="tool-call-config" atom="sql_query" module="Platform.Tools.ToolCallConfig.SQLQuery" -->
22
+
23
+ ## Tool Call Configuration (sql_query)
24
+
25
+ Fetches data via SQL query with Liquid template variables for pagination.
26
+
27
+ - **query** (TemplateConfig) — SQL query template with pagination variables
28
+
29
+ <!-- alvera:section kind="tool-call-config" atom="sftp_request" module="Platform.Tools.ToolCallConfig.SFTPRequest" -->
30
+
31
+ ## Tool Call Configuration (sftp_request)
32
+
33
+ Fetches data from a remote SFTP server.
34
+
35
+ - **path** (string) — Remote file path on SFTP server
36
+ - **content_type** (string) — MIME type of the file
37
+
38
+ <!-- alvera:section kind="tool-call-config" atom="microsoft_share_point_excel_request" module="Platform.Tools.ToolCallConfig.MicrosoftSharePointExcelRequest" -->
39
+
40
+ ## Tool Call Configuration (microsoft_share_point_excel_request)
41
+
42
+ Fetches data from a Microsoft SharePoint drive (Excel files).
43
+
44
+ - **drive_url** (string) — SharePoint drive URL
45
+ - **azure_tenant_id** (string) — Microsoft Azure tenant identifier
46
+ - **sheet_number** (integer) — 0-indexed Excel sheet number
47
+ - **search_params** (string) — Search parameters for locating files
48
+
49
+ <!-- alvera:section kind="tool-call-config" atom="aws_lambda_request" module="Platform.Tools.ToolCallConfig.AWSLambdaRequest" -->
50
+
51
+ ## Tool Call Configuration (aws_lambda_request)
52
+
53
+ Invokes an AWS Lambda function to fetch data.
54
+
55
+ - **payload** (TemplateConfig) — Lambda JSON payload, rendered as Liquid template
56
+ - **timeout_ms** (integer, default: 600000, max: 900000) — Invocation timeout in milliseconds
57
+
58
+ <!-- alvera:section kind="tool-call-config" atom="s3_request" module="Platform.Tools.ToolCallConfig.S3Request" -->
59
+
60
+ ## Tool Call Configuration (s3_request)
61
+
62
+ Fetches data from an S3 bucket.
63
+
64
+ - **file_path** (string) — S3 object key (no `s3://` prefix)
65
+
66
+ <!-- alvera:section kind="tool-call-config" atom="manual_upload" module="Platform.Tools.ToolCallConfig.ManualUpload" -->
67
+
68
+ ## Tool Call Configuration (manual_upload)
69
+
70
+ Manual file upload — data is uploaded directly by the user. No additional configuration fields.
71
+
72
+ <!-- alvera:section kind="tool-call-config" atom="sms_request" module="Platform.Tools.ToolCallConfig.SMSRequest" -->
73
+
74
+ ## Tool Call Configuration (sms_request)
75
+
76
+ Sends an SMS message via the configured SMS provider.
77
+
78
+ - **to** (TemplateConfig) — Recipient phone number in E.164 format, rendered as Liquid template
79
+ - **body** (TemplateConfig) — Message body, rendered as Liquid template
80
+ - **sms_type** (enum: transactional, promotional) — Message classification; defaults to `transactional`
81
+
82
+ <!-- alvera:section kind="tool-call-config" atom="email_request" module="Platform.Tools.ToolCallConfig.EmailRequest" -->
83
+
84
+ ## Tool Call Configuration (email_request)
85
+
86
+ Sends an email message via the configured email provider.
87
+
88
+ - **to** (TemplateConfig) — Recipient email address (RFC 5322), rendered as Liquid template
89
+ - **subject** (TemplateConfig) — Email subject line, rendered as Liquid template
90
+ - **body** (TemplateConfig) — Email body, rendered as Liquid template