@openmeshtak/sdk 0.0.0-stage → 0.2.1

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/LICENSE ADDED
@@ -0,0 +1,55 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
+
35
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
+
37
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
+
39
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
40
+
41
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
+
43
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # OpenMeshTak SDK
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official TypeScript and JavaScript client for the OpenMeshTak REST API.
4
+
5
+ The SDK is generated from the released OpenAPI contract and adds a small handwritten layer for
6
+ authentication, common operations and predictable problem-details errors. It does not duplicate
7
+ Core business rules. The SDK version always matches the OpenMeshTak version it was built from and
8
+ works with the later patch releases of that version line. Node.js 24 or newer is required.
9
+
10
+ Documentation: https://openmeshtak.github.io/openmeshtak-docs/sdk/
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ import { createOpenMeshTakClient, OpenMeshTakApiError } from "@openmeshtak/sdk";
16
+
17
+ const client = createOpenMeshTakClient({
18
+ baseUrl: "https://openmeshtak.example/api/v1",
19
+ apiKey: () => process.env.OPENMESHTAK_API_KEY ?? "",
20
+ });
21
+
22
+ try {
23
+ const event = await client.createEvent({
24
+ name: "LightSim 2027",
25
+ slug: "lightsim-2027",
26
+ timeZone: "Europe/Berlin",
27
+ });
28
+
29
+ console.log(event.id);
30
+ } catch (error) {
31
+ if (error instanceof OpenMeshTakApiError) {
32
+ console.error(error.status, error.code, error.traceId);
33
+ }
34
+ }
35
+ ```
36
+
37
+ `baseUrl` may be a server origin such as `http://127.0.0.1:3000`, in which case `/api/v1` is
38
+ added, or the complete API base URL. Embedded URL credentials, query strings and fragments are
39
+ rejected. Outside local development, use HTTPS.
40
+
41
+ The API key can be a string or an asynchronous provider, which makes key rotation possible without
42
+ recreating the client. Never put an API key in a URL or log it. When `apiKey` is omitted, browser
43
+ calls may use the Core session cookie according to the configured `credentials` mode.
44
+
45
+ ## Convenience surface
46
+
47
+ Each method maps to one API operation and throws `OpenMeshTakApiError` on a problem response.
48
+
49
+ - Caller: `getPrincipal`
50
+ - Events: `listEvents`, `createEvent`, `getEvent`, `updateEvent`, `activateEvent`, `archiveEvent`,
51
+ `reactivateEvent`
52
+ - Roles: `listEventRoles`, `createEventRole`, `getEventRole`, `updateEventRole`, `deleteEventRole`
53
+ - Groups: `listEventGroups`, `createEventGroup`, `getEventGroup`, `updateEventGroup`,
54
+ `deleteEventGroup`
55
+ - Members: `listEventMembers`, `createEventMember`, `createEventMemberAccount`, `getEventMember`,
56
+ `updateEventMember`, `deleteEventMember`, `upsertExternalMember`, `getMemberProfile`
57
+ - Sync issues: `listSyncIssues`, `retrySyncIssue`
58
+ - Member claims: `listMemberClaims`, `createMemberClaim`, `revokeMemberClaim`
59
+ - Configuration: `listConfigurationRevisions`, `publishConfiguration`, `getConfigurationRevision`
60
+
61
+ `createEventMemberAccount` and `createMemberClaim` return single-use links. Send them only to the
62
+ person they are for and never log them.
63
+
64
+ List methods return one page. `paginate` walks through all of them:
65
+
66
+ ```ts
67
+ import { paginate } from "@openmeshtak/sdk";
68
+
69
+ for await (const member of paginate((page) => client.listEventMembers(eventId, { limit: 100, ...page }))) {
70
+ console.log(member.id);
71
+ }
72
+ ```
73
+
74
+ Generated DTOs and operation types for every other operation are exported from
75
+ `@openmeshtak/sdk/generated`.
76
+
77
+ ## License
78
+
79
+ Apache-2.0
@@ -0,0 +1,56 @@
1
+ OpenMeshTak SDK third-party notices
2
+
3
+ OpenMeshTak SDK is licensed under Apache-2.0. Dependencies retain their own licenses.
4
+
5
+ ==============================================================================
6
+ openapi-fetch@0.17.0
7
+ License: MIT
8
+ https://openapi-ts.dev
9
+
10
+ MIT License
11
+
12
+ Copyright (c) 2023 Drew Powers
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ ==============================================================================
32
+ openapi-typescript-helpers@0.1.0
33
+ License: MIT
34
+ https://openapi-ts.dev
35
+
36
+ MIT License
37
+
38
+ Copyright (c) 2023 Drew Powers
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining a copy
41
+ of this software and associated documentation files (the "Software"), to deal
42
+ in the Software without restriction, including without limitation the rights
43
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
+ copies of the Software, and to permit persons to whom the Software is
45
+ furnished to do so, subject to the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be included in all
48
+ copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
+ SOFTWARE.
@@ -0,0 +1,69 @@
1
+ import type { ConfigurationRevision, ConfigurationRevisionPage, CreateEventGroupRequest, CreateEventMemberAccountRequest, CreateEventMemberRequest, CreateEventRequest, CreateEventRoleRequest, CreatedEventMemberAccount, CreatedMemberClaim, Event, EventGroup, EventGroupPage, EventMember, EventMemberPage, EventPage, EventRole, EventRolePage, EventTransitionRequest, ExternalMemberSyncRequest, ExternalMemberSyncResult, ExternalProvider, ListEventsOptions, ListSyncIssuesOptions, MemberClaim, PageOptions, Principal, PublishConfigurationResult, ResolvedProfile, RetrySyncIssueRequest, SyncIssuePage, UpdateEventGroupRequest, UpdateEventMemberRequest, UpdateEventRequest, UpdateEventRoleRequest } from "./types.js";
2
+ export type ApiKeyProvider = string | (() => string | Promise<string>);
3
+ export interface OpenMeshTakClientOptions {
4
+ /** Server origin or complete `/api/v1` base URL. */
5
+ baseUrl: string;
6
+ /** Machine credential. A provider is evaluated immediately before every request. */
7
+ apiKey?: ApiKeyProvider;
8
+ /** Browser cookie mode. Defaults to `same-origin`. */
9
+ credentials?: RequestInit["credentials"];
10
+ /** Fetch implementation for runtimes or tests. */
11
+ fetch?: typeof globalThis.fetch;
12
+ }
13
+ /**
14
+ * Typed convenience client for common integration tasks. Every method maps to one OpenAPI
15
+ * operation; the generated types in `@openmeshtak/sdk/generated` describe all others.
16
+ */
17
+ export declare class OpenMeshTakClient {
18
+ #private;
19
+ constructor(options: OpenMeshTakClientOptions);
20
+ /** The caller behind the configured credentials, for example to check an API key. */
21
+ getPrincipal(): Promise<Principal>;
22
+ listEvents(options?: ListEventsOptions): Promise<EventPage>;
23
+ createEvent(body: CreateEventRequest): Promise<Event>;
24
+ getEvent(eventId: string): Promise<Event>;
25
+ /** Replaces the editable settings; `body.version` must be the version last read. */
26
+ updateEvent(eventId: string, body: UpdateEventRequest): Promise<Event>;
27
+ activateEvent(eventId: string, body: EventTransitionRequest): Promise<Event>;
28
+ archiveEvent(eventId: string, body: EventTransitionRequest): Promise<Event>;
29
+ reactivateEvent(eventId: string, body: EventTransitionRequest): Promise<Event>;
30
+ listEventRoles(eventId: string, options?: PageOptions): Promise<EventRolePage>;
31
+ createEventRole(eventId: string, body: CreateEventRoleRequest): Promise<EventRole>;
32
+ getEventRole(eventId: string, roleId: string): Promise<EventRole>;
33
+ updateEventRole(eventId: string, roleId: string, body: UpdateEventRoleRequest): Promise<EventRole>;
34
+ deleteEventRole(eventId: string, roleId: string): Promise<void>;
35
+ listEventGroups(eventId: string, options?: PageOptions): Promise<EventGroupPage>;
36
+ createEventGroup(eventId: string, body: CreateEventGroupRequest): Promise<EventGroup>;
37
+ getEventGroup(eventId: string, groupId: string): Promise<EventGroup>;
38
+ updateEventGroup(eventId: string, groupId: string, body: UpdateEventGroupRequest): Promise<EventGroup>;
39
+ deleteEventGroup(eventId: string, groupId: string): Promise<void>;
40
+ listEventMembers(eventId: string, options?: PageOptions): Promise<EventMemberPage>;
41
+ /** Adds an existing OpenMeshTak user. Members from external systems use `upsertExternalMember`. */
42
+ createEventMember(eventId: string, body: CreateEventMemberRequest): Promise<EventMember>;
43
+ /**
44
+ * Creates a new person and adds them to the event. The result contains a single-use setup link;
45
+ * hand it only to that person and never log it.
46
+ */
47
+ createEventMemberAccount(eventId: string, body: CreateEventMemberAccountRequest): Promise<CreatedEventMemberAccount>;
48
+ getEventMember(eventId: string, memberId: string): Promise<EventMember>;
49
+ updateEventMember(eventId: string, memberId: string, body: UpdateEventMemberRequest): Promise<EventMember>;
50
+ deleteEventMember(eventId: string, memberId: string): Promise<void>;
51
+ /** Creates or updates the member an external system knows by `provider` plus `externalId`. */
52
+ upsertExternalMember(eventId: string, provider: ExternalProvider, externalId: string, body: ExternalMemberSyncRequest): Promise<ExternalMemberSyncResult>;
53
+ getMemberProfile(eventId: string, memberId: string): Promise<ResolvedProfile>;
54
+ listSyncIssues(eventId: string, options?: ListSyncIssuesOptions): Promise<SyncIssuePage>;
55
+ retrySyncIssue(eventId: string, syncIssueId: string, body?: RetrySyncIssueRequest): Promise<ExternalMemberSyncResult>;
56
+ listMemberClaims(eventId: string, memberId: string): Promise<MemberClaim[]>;
57
+ /**
58
+ * Creates a single-use claim link for a member. Token and link are returned only here; send them
59
+ * only to that member and never log them.
60
+ */
61
+ createMemberClaim(eventId: string, memberId: string): Promise<CreatedMemberClaim>;
62
+ revokeMemberClaim(eventId: string, memberId: string, claimId: string): Promise<MemberClaim>;
63
+ listConfigurationRevisions(eventId: string, options?: PageOptions): Promise<ConfigurationRevisionPage>;
64
+ /** Publishes the current configuration of an active event; `created` is false when unchanged. */
65
+ publishConfiguration(eventId: string): Promise<PublishConfigurationResult>;
66
+ getConfigurationRevision(eventId: string, revisionId: string): Promise<ConfigurationRevision>;
67
+ }
68
+ export declare function createOpenMeshTakClient(options: OpenMeshTakClientOptions): OpenMeshTakClient;
69
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,+BAA+B,EAC/B,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,SAAS,EACT,SAAS,EACT,aAAa,EACb,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,SAAS,EACT,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,MAAM,MA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AAG,OAAO,CAAC,qBAAqB,CAAC;CAO9F;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAE5F"}
package/dist/client.js ADDED
@@ -0,0 +1,202 @@
1
+ import createClient, {} from "openapi-fetch";
2
+ import { OpenMeshTakApiError } from "./errors.js";
3
+ function normalizeBaseUrl(input) {
4
+ const url = new URL(input);
5
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
6
+ throw new TypeError("OpenMeshTak baseUrl must use HTTP or HTTPS.");
7
+ }
8
+ if (url.username !== "" || url.password !== "") {
9
+ throw new TypeError("OpenMeshTak baseUrl must not contain credentials.");
10
+ }
11
+ if (url.search !== "" || url.hash !== "") {
12
+ throw new TypeError("OpenMeshTak baseUrl must not contain a query string or fragment.");
13
+ }
14
+ const path = url.pathname.replace(/\/+$/, "");
15
+ url.pathname = path === "" ? "/api/v1" : path;
16
+ return url.href;
17
+ }
18
+ async function resolveApiKey(provider) {
19
+ // JavaScript callers can bypass the type, so check the runtime value before using it.
20
+ const value = typeof provider === "function" ? await provider() : provider;
21
+ if (typeof value !== "string" || value === "") {
22
+ throw new TypeError("The API key provider returned no OpenMeshTak API key.");
23
+ }
24
+ if (!value.startsWith("omtk_ak_") || value.length <= "omtk_ak_".length) {
25
+ throw new TypeError("The API key provider returned an invalid OpenMeshTak API key.");
26
+ }
27
+ return value;
28
+ }
29
+ async function unwrap(call) {
30
+ const { data, error, response } = await call;
31
+ if (!response.ok || error !== undefined) {
32
+ throw new OpenMeshTakApiError(response, error);
33
+ }
34
+ return data;
35
+ }
36
+ async function unwrapEmpty(call) {
37
+ await unwrap(call);
38
+ }
39
+ /**
40
+ * Typed convenience client for common integration tasks. Every method maps to one OpenAPI
41
+ * operation; the generated types in `@openmeshtak/sdk/generated` describe all others.
42
+ */
43
+ export class OpenMeshTakClient {
44
+ #api;
45
+ constructor(options) {
46
+ const clientOptions = {
47
+ baseUrl: normalizeBaseUrl(options.baseUrl),
48
+ credentials: options.credentials ?? "same-origin",
49
+ };
50
+ if (options.fetch !== undefined) {
51
+ clientOptions.fetch = options.fetch;
52
+ }
53
+ this.#api = createClient(clientOptions);
54
+ if (options.apiKey !== undefined) {
55
+ const provider = options.apiKey;
56
+ this.#api.use({
57
+ async onRequest({ request }) {
58
+ request.headers.set("Authorization", `Bearer ${await resolveApiKey(provider)}`);
59
+ return request;
60
+ },
61
+ });
62
+ }
63
+ }
64
+ /** The caller behind the configured credentials, for example to check an API key. */
65
+ getPrincipal() {
66
+ return unwrap(this.#api.GET("/principal"));
67
+ }
68
+ // Events
69
+ listEvents(options = {}) {
70
+ return unwrap(this.#api.GET("/events", { params: { query: options } }));
71
+ }
72
+ createEvent(body) {
73
+ return unwrap(this.#api.POST("/events", { body }));
74
+ }
75
+ getEvent(eventId) {
76
+ return unwrap(this.#api.GET("/events/{eventId}", { params: { path: { eventId } } }));
77
+ }
78
+ /** Replaces the editable settings; `body.version` must be the version last read. */
79
+ updateEvent(eventId, body) {
80
+ return unwrap(this.#api.PUT("/events/{eventId}", { params: { path: { eventId } }, body }));
81
+ }
82
+ activateEvent(eventId, body) {
83
+ return unwrap(this.#api.POST("/events/{eventId}/activate", { params: { path: { eventId } }, body }));
84
+ }
85
+ archiveEvent(eventId, body) {
86
+ return unwrap(this.#api.POST("/events/{eventId}/archive", { params: { path: { eventId } }, body }));
87
+ }
88
+ reactivateEvent(eventId, body) {
89
+ return unwrap(this.#api.POST("/events/{eventId}/reactivate", { params: { path: { eventId } }, body }));
90
+ }
91
+ // Event roles
92
+ listEventRoles(eventId, options = {}) {
93
+ return unwrap(this.#api.GET("/events/{eventId}/roles", { params: { path: { eventId }, query: options } }));
94
+ }
95
+ createEventRole(eventId, body) {
96
+ return unwrap(this.#api.POST("/events/{eventId}/roles", { params: { path: { eventId } }, body }));
97
+ }
98
+ getEventRole(eventId, roleId) {
99
+ return unwrap(this.#api.GET("/events/{eventId}/roles/{roleId}", { params: { path: { eventId, roleId } } }));
100
+ }
101
+ updateEventRole(eventId, roleId, body) {
102
+ return unwrap(this.#api.PUT("/events/{eventId}/roles/{roleId}", { params: { path: { eventId, roleId } }, body }));
103
+ }
104
+ deleteEventRole(eventId, roleId) {
105
+ return unwrapEmpty(this.#api.DELETE("/events/{eventId}/roles/{roleId}", { params: { path: { eventId, roleId } } }));
106
+ }
107
+ // Event groups
108
+ listEventGroups(eventId, options = {}) {
109
+ return unwrap(this.#api.GET("/events/{eventId}/groups", { params: { path: { eventId }, query: options } }));
110
+ }
111
+ createEventGroup(eventId, body) {
112
+ return unwrap(this.#api.POST("/events/{eventId}/groups", { params: { path: { eventId } }, body }));
113
+ }
114
+ getEventGroup(eventId, groupId) {
115
+ return unwrap(this.#api.GET("/events/{eventId}/groups/{groupId}", { params: { path: { eventId, groupId } } }));
116
+ }
117
+ updateEventGroup(eventId, groupId, body) {
118
+ return unwrap(this.#api.PUT("/events/{eventId}/groups/{groupId}", { params: { path: { eventId, groupId } }, body }));
119
+ }
120
+ deleteEventGroup(eventId, groupId) {
121
+ return unwrapEmpty(this.#api.DELETE("/events/{eventId}/groups/{groupId}", { params: { path: { eventId, groupId } } }));
122
+ }
123
+ // Event members
124
+ listEventMembers(eventId, options = {}) {
125
+ return unwrap(this.#api.GET("/events/{eventId}/members", { params: { path: { eventId }, query: options } }));
126
+ }
127
+ /** Adds an existing OpenMeshTak user. Members from external systems use `upsertExternalMember`. */
128
+ createEventMember(eventId, body) {
129
+ return unwrap(this.#api.POST("/events/{eventId}/members", { params: { path: { eventId } }, body }));
130
+ }
131
+ /**
132
+ * Creates a new person and adds them to the event. The result contains a single-use setup link;
133
+ * hand it only to that person and never log it.
134
+ */
135
+ createEventMemberAccount(eventId, body) {
136
+ return unwrap(this.#api.POST("/events/{eventId}/members/accounts", { params: { path: { eventId } }, body }));
137
+ }
138
+ getEventMember(eventId, memberId) {
139
+ return unwrap(this.#api.GET("/events/{eventId}/members/{memberId}", { params: { path: { eventId, memberId } } }));
140
+ }
141
+ updateEventMember(eventId, memberId, body) {
142
+ return unwrap(this.#api.PUT("/events/{eventId}/members/{memberId}", { params: { path: { eventId, memberId } }, body }));
143
+ }
144
+ deleteEventMember(eventId, memberId) {
145
+ return unwrapEmpty(this.#api.DELETE("/events/{eventId}/members/{memberId}", { params: { path: { eventId, memberId } } }));
146
+ }
147
+ /** Creates or updates the member an external system knows by `provider` plus `externalId`. */
148
+ upsertExternalMember(eventId, provider, externalId, body) {
149
+ return unwrap(this.#api.PUT("/events/{eventId}/external-members/{provider}/{externalId}", {
150
+ params: { path: { eventId, provider, externalId } },
151
+ body,
152
+ }));
153
+ }
154
+ getMemberProfile(eventId, memberId) {
155
+ return unwrap(this.#api.GET("/events/{eventId}/members/{memberId}/profile", {
156
+ params: { path: { eventId, memberId } },
157
+ }));
158
+ }
159
+ // Sync issues
160
+ listSyncIssues(eventId, options = {}) {
161
+ return unwrap(this.#api.GET("/events/{eventId}/sync-issues", { params: { path: { eventId }, query: options } }));
162
+ }
163
+ retrySyncIssue(eventId, syncIssueId, body = {}) {
164
+ return unwrap(this.#api.POST("/events/{eventId}/sync-issues/{syncIssueId}/retry", {
165
+ params: { path: { eventId, syncIssueId } },
166
+ body,
167
+ }));
168
+ }
169
+ // Member claims
170
+ listMemberClaims(eventId, memberId) {
171
+ return unwrap(this.#api.GET("/events/{eventId}/members/{memberId}/claims", { params: { path: { eventId, memberId } } }));
172
+ }
173
+ /**
174
+ * Creates a single-use claim link for a member. Token and link are returned only here; send them
175
+ * only to that member and never log them.
176
+ */
177
+ createMemberClaim(eventId, memberId) {
178
+ return unwrap(this.#api.POST("/events/{eventId}/members/{memberId}/claims", { params: { path: { eventId, memberId } } }));
179
+ }
180
+ revokeMemberClaim(eventId, memberId, claimId) {
181
+ return unwrap(this.#api.POST("/events/{eventId}/members/{memberId}/claims/{claimId}/revoke", {
182
+ params: { path: { eventId, memberId, claimId } },
183
+ }));
184
+ }
185
+ // Configuration revisions
186
+ listConfigurationRevisions(eventId, options = {}) {
187
+ return unwrap(this.#api.GET("/events/{eventId}/configuration-revisions", { params: { path: { eventId }, query: options } }));
188
+ }
189
+ /** Publishes the current configuration of an active event; `created` is false when unchanged. */
190
+ publishConfiguration(eventId) {
191
+ return unwrap(this.#api.POST("/events/{eventId}/configuration-revisions", { params: { path: { eventId } } }));
192
+ }
193
+ getConfigurationRevision(eventId, revisionId) {
194
+ return unwrap(this.#api.GET("/events/{eventId}/configuration-revisions/{revisionId}", {
195
+ params: { path: { eventId, revisionId } },
196
+ }));
197
+ }
198
+ }
199
+ export function createOpenMeshTakClient(options) {
200
+ return new OpenMeshTakClient(options);
201
+ }
202
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAmC,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAyDlD,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAE3B,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1D,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;QACzC,MAAM,IAAI,SAAS,CAAC,kEAAkE,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;I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AAe,EAAE,QAAgB,EAAE,OAAe;QAClE,OAAO,MAAM,CACX,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,8DAA8D,EAAE;YAC7E,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;SACjD,CAAC,CACH,CAAC;IACJ,CAAC;IAED,0BAA0B;IAE1B,0BAA0B,CAAC,OAAe,EAAE,UAAuB,EAAE;QACnE,OAAO,MAAM,CACX,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,2CAA2C,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAC9G,CAAC;IACJ,CAAC;IAED,iGAAiG;IACjG,oBAAoB,CAAC,OAAe;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,2CAA2C,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAChH,CAAC;IAED,wBAAwB,CAAC,OAAe,EAAE,UAAkB;QAC1D,OAAO,MAAM,CACX,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,wDAAwD,EAAE;YACtE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;SAC1C,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAiC;IACvE,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { components } from "./generated/schema.js";
2
+ export type ProblemDetails = components["schemas"]["ProblemDetails"];
3
+ /** A safe RFC 9457 problem returned by OpenMeshTak Core. */
4
+ export declare class OpenMeshTakApiError extends Error {
5
+ readonly status: number;
6
+ readonly problem: ProblemDetails | undefined;
7
+ readonly type: string | undefined;
8
+ readonly code: string | undefined;
9
+ readonly traceId: string | undefined;
10
+ constructor(response: Response, body: unknown);
11
+ }
12
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAgBrE,4DAA4D;AAC5D,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEzB,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO;CAU9C"}
package/dist/errors.js ADDED
@@ -0,0 +1,29 @@
1
+ function isProblemDetails(value) {
2
+ if (typeof value !== "object" || value === null) {
3
+ return false;
4
+ }
5
+ const candidate = value;
6
+ return (typeof candidate.type === "string" &&
7
+ typeof candidate.title === "string" &&
8
+ typeof candidate.status === "number" &&
9
+ typeof candidate.code === "string");
10
+ }
11
+ /** A safe RFC 9457 problem returned by OpenMeshTak Core. */
12
+ export class OpenMeshTakApiError extends Error {
13
+ status;
14
+ problem;
15
+ type;
16
+ code;
17
+ traceId;
18
+ constructor(response, body) {
19
+ const problem = isProblemDetails(body) ? body : undefined;
20
+ super(problem?.detail ?? problem?.title ?? `OpenMeshTak API request failed with status ${response.status}.`);
21
+ this.name = "OpenMeshTakApiError";
22
+ this.status = response.status;
23
+ this.problem = problem;
24
+ this.type = problem?.type;
25
+ this.code = problem?.code;
26
+ this.traceId = problem?.traceId;
27
+ }
28
+ }
29
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAIA,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,KAAgC,CAAC;IACnD,OAAO,CACL,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ;QACnC,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ;QACpC,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,CACnC,CAAC;AACJ,CAAC;AAED,4DAA4D;AAC5D,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,MAAM,CAAS;IACf,OAAO,CAA6B;IACpC,IAAI,CAAqB;IACzB,IAAI,CAAqB;IACzB,OAAO,CAAqB;IAErC,YAAY,QAAkB,EAAE,IAAa;QAC3C,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,KAAK,IAAI,8CAA8C,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,O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