@surfiran/public-api-client 0.27.0 → 0.29.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/README.md +10 -8
- package/dist/client.d.ts +1 -3
- package/dist/client.js +18 -1
- package/dist/types.d.ts +15 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Public API Client
|
|
2
2
|
|
|
3
|
-
Zero-runtime-dependency TypeScript types and fetch client for SURFIRAN Public API V1. The checked-in package-local contract snapshot is OpenAPI `v0.
|
|
3
|
+
Zero-runtime-dependency TypeScript types and fetch client for SURFIRAN Public API V1. The checked-in package-local contract snapshot is OpenAPI `v0.18.0`.
|
|
4
4
|
|
|
5
5
|
Repository: `SURFIRAN/surfiran-public-api-client`
|
|
6
6
|
|
|
@@ -18,11 +18,11 @@ The repository split and production cutover are complete. This repository is the
|
|
|
18
18
|
|
|
19
19
|
`contract/public-api-v1.yaml` is the package-local immutable snapshot used for generation. `contract/provenance.json` records its source identity, immutable source revision, checksums, and, for standalone releases, the exact API artifact identity.
|
|
20
20
|
|
|
21
|
-
The checked-in `0.
|
|
21
|
+
The checked-in `0.29.0` snapshot and provenance come from the `SURFIRAN/surfiran-crm-api` main-branch release `public-api-contract/ad9252578477406f13cb7db52e4f12c32715b00e-36233980383-1`. Published `0.20.0` and earlier keep their historical provenance, which may still reference the former monorepo owner or path. Do not rewrite an already published package version solely to rename historical provenance.
|
|
22
22
|
|
|
23
|
-
New client versions must consume
|
|
23
|
+
New client versions must consume the exact immutable GitHub Release assets produced from a successful `SURFIRAN/surfiran-crm-api` main-branch CI run. The release tag is `public-api-contract/<source SHA>-<run ID>-<attempt>` and contains only `public-api-v1.yaml` and `manifest.json`. Publication verifies the immutable release and both GitHub release attestations, the tag SHA, final successful source run, asset digests, manifest identity, and checked-in snapshot bytes. If any check is unavailable, publication stops. Pull-request artifacts are verification evidence only and are not valid release inputs. This repository must never read another repository's private working tree at build time.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
`src/generated/public-api-v1.ts` is generated from the checked-in snapshot; `src/client.ts` and `src/types.ts` are maintained in this repository against that reviewed contract. Never hand-edit generated source.
|
|
26
26
|
|
|
27
27
|
## Boundary
|
|
28
28
|
|
|
@@ -65,9 +65,9 @@ Generation is deterministic: stable ordering and formatting, LF newlines, no mac
|
|
|
65
65
|
|
|
66
66
|
A new contract update must:
|
|
67
67
|
|
|
68
|
-
1. use the exact immutable
|
|
68
|
+
1. use the exact immutable release assets from a successful API run on `refs/heads/main` triggered by `push` or `workflow_dispatch`;
|
|
69
69
|
2. make a reviewed package version change before rewriting contract provenance;
|
|
70
|
-
3. run `sync:api-contract-artifact` with the exact API commit, run ID, and run attempt;
|
|
70
|
+
3. verify/download the release assets, then run `sync:api-contract-artifact` with the exact API commit, run ID, and run attempt;
|
|
71
71
|
4. update `contract/public-api-v1.yaml` and `contract/provenance.json` together;
|
|
72
72
|
5. regenerate the client;
|
|
73
73
|
6. pass artifact verification, package verification, reproducibility, tests, typecheck, and build;
|
|
@@ -83,7 +83,9 @@ Do not duplicate the endpoint list here; the pinned OpenAPI snapshot and generat
|
|
|
83
83
|
|
|
84
84
|
## Publication and rollback
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
Routine package CI runs on the non-production Linux `ci-worker` pool. Manual publication uses the dedicated trusted `package-publish` runner and never occupies `surfdmc-prod-deploy`; package and cross-repository artifact credentials do not move to Home or general CI workers.
|
|
87
|
+
|
|
88
|
+
Publication is manual and repository-local through [public-api-client-publish.yml](.github/workflows/public-api-client-publish.yml). It runs on `main` only with explicit publication authorization and `publish_confirm=PUBLISH`. A future version must be bound to an exact reviewed API contract release, pass package/reproducibility checks and publication preflight, create release provenance, and provide an exact previous rollback version. The workflow uses `PUBLIC_API_CONTRACT_READ_TOKEN` to read the private immutable API release and a separate `PUBLIC_API_CLIENT_RELEASE_SETTINGS_READ_TOKEN` with scoped Administration:read to confirm immutable Releases are enabled for this client repository. Before publishing to npmjs.org, it creates or exactly reuses an immutable client release `public-api-client/v<package version>` containing the packed tarball and provenance JSON. It marks the evidence release as non-latest and verifies its asset digests, source tag SHA, and GitHub release attestations. Retries must reproduce the same bytes, including the explicit generation timestamp. Missing or unverifiable release or publication evidence blocks npm publication; the workflow does not use Actions artifact storage for these gates.
|
|
87
89
|
|
|
88
90
|
Published versions are immutable. Rollback means pinning consumers to the previous verified exact package version. Package publication never deploys a consumer, changes API runtime behavior, applies a database migration, or authorizes production data/configuration access.
|
|
89
91
|
|
|
@@ -92,6 +94,6 @@ Published versions are immutable. Rollback means pinning consumers to the previo
|
|
|
92
94
|
- This README owns local setup, contract synchronization, CI, publication, and rollback guidance.
|
|
93
95
|
- [AGENTS.md](AGENTS.md) owns agent operating instructions.
|
|
94
96
|
- [Repository boundaries and documentation governance](https://github.com/SURFIRAN/surfiran-crm-api/blob/main/docs/architecture/REPOSITORY_BOUNDARIES.md) own shared architecture and current system state.
|
|
95
|
-
- [Contract snapshot](contract/public-api-v1.yaml) and [provenance](contract/provenance.json) are immutable evidence for `0.
|
|
97
|
+
- [Contract snapshot](contract/public-api-v1.yaml) and [provenance](contract/provenance.json) are immutable evidence for `0.29.0`, not current API ownership authorities.
|
|
96
98
|
|
|
97
99
|
Update existing guidance instead of creating duplicate contract or publication authorities. Preserve the historical snapshot, provenance, and generated bytes until a reviewed new package version imports a verified API artifact.
|
package/dist/client.d.ts
CHANGED
|
@@ -4,9 +4,7 @@ export type PublicApiClientOptions = {
|
|
|
4
4
|
fetchImpl?: typeof fetch;
|
|
5
5
|
requestId?: string;
|
|
6
6
|
/**
|
|
7
|
-
* Bounds every request issued by this client. Defaults to 10000ms
|
|
8
|
-
* the existing AbortController-based timeout precedent in
|
|
9
|
-
* server/services/webhookDispatcher.ts.
|
|
7
|
+
* Bounds every request issued by this client. Defaults to 10000ms.
|
|
10
8
|
*/
|
|
11
9
|
timeoutMs?: number;
|
|
12
10
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
const DEFAULT_TIMEOUT_MS = 10000;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Trims trailing slashes without a regular expression.
|
|
4
|
+
*
|
|
5
|
+
* `/\/+$/` has a candidate start at every slash, so a base URL ending in a
|
|
6
|
+
* long run of them was quadratic to reject (CodeQL js/polynomial-redos). This
|
|
7
|
+
* is a published client library: the base URL is whatever a consumer passes,
|
|
8
|
+
* and a library has no say in that. Scanning backwards is linear and says the
|
|
9
|
+
* same thing.
|
|
10
|
+
*/
|
|
11
|
+
const SLASH = 47;
|
|
12
|
+
const trimTrailingSlash = (value) => {
|
|
13
|
+
let end = value.length;
|
|
14
|
+
while (end > 0 && value.charCodeAt(end - 1) === SLASH)
|
|
15
|
+
end -= 1;
|
|
16
|
+
return value.slice(0, end);
|
|
17
|
+
};
|
|
3
18
|
const isAbortError = (err) => err instanceof Error && err.name === 'AbortError';
|
|
4
19
|
const toTimeoutResult = (status, requestId) => ({
|
|
5
20
|
ok: false,
|
|
@@ -130,6 +145,8 @@ const toSearchResultsQueryString = (params) => {
|
|
|
130
145
|
search.set('limit', String(params.limit));
|
|
131
146
|
if (params.type)
|
|
132
147
|
search.set('type', params.type);
|
|
148
|
+
if (params.locale)
|
|
149
|
+
search.set('locale', params.locale);
|
|
133
150
|
return `?${search.toString()}`;
|
|
134
151
|
};
|
|
135
152
|
const toTravelKnowledgeQueryString = (params) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -1002,6 +1002,18 @@ export type PublicSearchResultItem = {
|
|
|
1002
1002
|
slug: string;
|
|
1003
1003
|
path: string;
|
|
1004
1004
|
summary: string | null;
|
|
1005
|
+
/**
|
|
1006
|
+
* Present only when a non-English locale was explicitly requested. Locale of
|
|
1007
|
+
* the displayed label, from approved field provenance; `en` means the English
|
|
1008
|
+
* source is displayed as a fallback (always the case for destinations).
|
|
1009
|
+
*/
|
|
1010
|
+
labelSourceLocale?: PublicContentLocale;
|
|
1011
|
+
/**
|
|
1012
|
+
* Present only when a non-English locale was explicitly requested. Locale of
|
|
1013
|
+
* the displayed summary, from approved field provenance; null when `summary`
|
|
1014
|
+
* is null, and `en` when the English source is displayed as a fallback.
|
|
1015
|
+
*/
|
|
1016
|
+
summarySourceLocale?: PublicContentLocale | null;
|
|
1005
1017
|
};
|
|
1006
1018
|
export type PublicSearchResultGroup = {
|
|
1007
1019
|
type: 'tour' | 'destination';
|
|
@@ -1566,7 +1578,7 @@ export type ListPublicToursParams = {
|
|
|
1566
1578
|
locale?: PublicContentLocale;
|
|
1567
1579
|
};
|
|
1568
1580
|
/** Locales the public content contract will resolve translations for. */
|
|
1569
|
-
export type PublicContentLocale = 'en' | 'de' | 'fr' | 'es' | 'it' | 'fa' | 'ar';
|
|
1581
|
+
export type PublicContentLocale = 'en' | 'de' | 'fr' | 'tr' | 'ru' | 'es' | 'it' | 'fa' | 'ar';
|
|
1570
1582
|
export type GetPublicTourParams = {
|
|
1571
1583
|
/** See ListPublicToursParams['locale']. */
|
|
1572
1584
|
locale?: PublicContentLocale;
|
|
@@ -1623,6 +1635,8 @@ export type GetPublicSearchResultsParams = {
|
|
|
1623
1635
|
/** Maximum items per group. 1 through 25; defaults to 10 server-side. Group totals still report every match. */
|
|
1624
1636
|
limit?: number;
|
|
1625
1637
|
type?: 'tour' | 'destination';
|
|
1638
|
+
/** Published tour copy locale; omitted or en keeps the English results. */
|
|
1639
|
+
locale?: PublicContentLocale;
|
|
1626
1640
|
};
|
|
1627
1641
|
export type ListPublicTourCategoriesParams = {
|
|
1628
1642
|
limit?: number;
|
package/dist/types.js
CHANGED