@apito-io/js-admin-sdk 2.0.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/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/index.d.mts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +135 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +82 -0
- package/src/__tests__/client.test.ts +493 -0
- package/src/client.ts +467 -0
- package/src/index.ts +30 -0
- package/src/typed-operations.ts +93 -0
- package/src/types.ts +170 -0
- package/src/version.ts +11 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Apito JavaScript SDK
|
|
3
|
+
*/
|
|
4
|
+
interface MetaField {
|
|
5
|
+
created_at: string;
|
|
6
|
+
updated_at: string;
|
|
7
|
+
status: string;
|
|
8
|
+
revision?: string;
|
|
9
|
+
revision_at?: string;
|
|
10
|
+
root_revision_id?: string;
|
|
11
|
+
}
|
|
12
|
+
interface DefaultDocumentStructure {
|
|
13
|
+
_key?: string;
|
|
14
|
+
_id?: string;
|
|
15
|
+
data: any;
|
|
16
|
+
meta?: MetaField;
|
|
17
|
+
id: string;
|
|
18
|
+
expire_at?: string | number;
|
|
19
|
+
relation_doc_id?: string;
|
|
20
|
+
last_revision_doc_id?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
tenant_id?: string;
|
|
23
|
+
tenant_model?: string;
|
|
24
|
+
}
|
|
25
|
+
interface SearchResult {
|
|
26
|
+
results: DefaultDocumentStructure[];
|
|
27
|
+
count: number;
|
|
28
|
+
}
|
|
29
|
+
interface TypedDocumentStructure<T> {
|
|
30
|
+
_key?: string;
|
|
31
|
+
_id?: string;
|
|
32
|
+
data: T;
|
|
33
|
+
meta?: MetaField;
|
|
34
|
+
id: string;
|
|
35
|
+
expire_at?: string | number;
|
|
36
|
+
relation_doc_id?: string;
|
|
37
|
+
last_revision_doc_id?: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
tenant_id?: string;
|
|
40
|
+
tenant_model?: string;
|
|
41
|
+
}
|
|
42
|
+
interface TypedSearchResult<T> {
|
|
43
|
+
results: TypedDocumentStructure<T>[];
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
interface Filter {
|
|
47
|
+
page?: number;
|
|
48
|
+
offset?: number;
|
|
49
|
+
limit?: number;
|
|
50
|
+
order?: string;
|
|
51
|
+
min?: number;
|
|
52
|
+
max?: number;
|
|
53
|
+
category?: string;
|
|
54
|
+
}
|
|
55
|
+
interface GraphQLErrorLocation {
|
|
56
|
+
line: number;
|
|
57
|
+
column: number;
|
|
58
|
+
}
|
|
59
|
+
interface GraphQLResponse {
|
|
60
|
+
data?: any;
|
|
61
|
+
errors?: GraphQLError[];
|
|
62
|
+
}
|
|
63
|
+
interface CreateAndUpdateRequest {
|
|
64
|
+
id?: string;
|
|
65
|
+
model: string;
|
|
66
|
+
payload: any;
|
|
67
|
+
connect?: Record<string, any>;
|
|
68
|
+
disconnect?: Record<string, any>;
|
|
69
|
+
singlePageData?: boolean;
|
|
70
|
+
forceUpdate?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface ClientConfig {
|
|
73
|
+
baseURL: string;
|
|
74
|
+
apiKey: string;
|
|
75
|
+
timeout?: number;
|
|
76
|
+
httpClient?: any;
|
|
77
|
+
tenantId?: string;
|
|
78
|
+
}
|
|
79
|
+
interface RequestOptions {
|
|
80
|
+
headers?: Record<string, string>;
|
|
81
|
+
timeout?: number;
|
|
82
|
+
}
|
|
83
|
+
interface SearchOptions {
|
|
84
|
+
limit?: number;
|
|
85
|
+
page?: number;
|
|
86
|
+
offset?: number;
|
|
87
|
+
where?: Record<string, any>;
|
|
88
|
+
search?: string;
|
|
89
|
+
sort?: Record<string, 1 | -1>;
|
|
90
|
+
}
|
|
91
|
+
interface ConnectionOptions {
|
|
92
|
+
model: string;
|
|
93
|
+
filter?: SearchOptions;
|
|
94
|
+
}
|
|
95
|
+
interface InjectedDBOperationInterface {
|
|
96
|
+
generateTenantToken(token: string, tenantId: string): Promise<string>;
|
|
97
|
+
getSingleResource(model: string, id: string, singlePageData?: boolean): Promise<DefaultDocumentStructure>;
|
|
98
|
+
searchResources(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<SearchResult>;
|
|
99
|
+
getRelationDocuments(id: string, connection: Record<string, any>): Promise<SearchResult>;
|
|
100
|
+
createNewResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;
|
|
101
|
+
updateResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;
|
|
102
|
+
deleteResource(model: string, id: string): Promise<void>;
|
|
103
|
+
debug(stage: string, ...data: any[]): Promise<any>;
|
|
104
|
+
}
|
|
105
|
+
declare class ApitoError extends Error {
|
|
106
|
+
code?: string;
|
|
107
|
+
statusCode?: number;
|
|
108
|
+
details?: any;
|
|
109
|
+
constructor(message: string, code?: string, statusCode?: number, details?: any);
|
|
110
|
+
}
|
|
111
|
+
interface GraphQLError {
|
|
112
|
+
message: string;
|
|
113
|
+
locations?: GraphQLErrorLocation[];
|
|
114
|
+
path?: (string | number)[];
|
|
115
|
+
extensions?: Record<string, any>;
|
|
116
|
+
}
|
|
117
|
+
declare class GraphQLError extends ApitoError {
|
|
118
|
+
graphQLErrors: GraphQLError[];
|
|
119
|
+
response?: any;
|
|
120
|
+
constructor(message: string, graphQLErrors: GraphQLError[], response?: any);
|
|
121
|
+
get partialData(): any;
|
|
122
|
+
}
|
|
123
|
+
declare class ValidationError extends ApitoError {
|
|
124
|
+
field?: string;
|
|
125
|
+
constructor(message: string, field?: string);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Apito SDK Client - JavaScript implementation matching the Go SDK
|
|
130
|
+
*/
|
|
131
|
+
declare class ApitoClient implements InjectedDBOperationInterface {
|
|
132
|
+
private httpClient;
|
|
133
|
+
private baseURL;
|
|
134
|
+
private apiKey;
|
|
135
|
+
private tenantId?;
|
|
136
|
+
constructor(config: ClientConfig);
|
|
137
|
+
/**
|
|
138
|
+
* Execute a GraphQL query or mutation
|
|
139
|
+
*/
|
|
140
|
+
private executeGraphQL;
|
|
141
|
+
/**
|
|
142
|
+
* Generate a new tenant token for the specified tenant ID
|
|
143
|
+
*/
|
|
144
|
+
generateTenantToken(token: string, tenantId: string): Promise<string>;
|
|
145
|
+
/**
|
|
146
|
+
* Get a single resource by model and ID
|
|
147
|
+
*/
|
|
148
|
+
getSingleResource(model: string, id: string, singlePageData?: boolean): Promise<DefaultDocumentStructure>;
|
|
149
|
+
/**
|
|
150
|
+
* Search resources in a model
|
|
151
|
+
*/
|
|
152
|
+
searchResources(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<SearchResult>;
|
|
153
|
+
/**
|
|
154
|
+
* Get related documents
|
|
155
|
+
*/
|
|
156
|
+
getRelationDocuments(id: string, connection: Record<string, any>): Promise<SearchResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Create a new resource
|
|
159
|
+
*/
|
|
160
|
+
createNewResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;
|
|
161
|
+
/**
|
|
162
|
+
* Update an existing resource
|
|
163
|
+
*/
|
|
164
|
+
updateResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;
|
|
165
|
+
/**
|
|
166
|
+
* Delete a resource by model and ID
|
|
167
|
+
*/
|
|
168
|
+
deleteResource(model: string, id: string): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Debug is used to debug the plugin, you can pass data here to debug the plugin
|
|
171
|
+
*/
|
|
172
|
+
debug(stage: string, ...data: any[]): Promise<any>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Factory function to create a new Apito client
|
|
176
|
+
*/
|
|
177
|
+
declare function createClient(config: ClientConfig): ApitoClient;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Typed operations wrapper for the Apito SDK
|
|
181
|
+
* Provides type-safe methods for working with typed data
|
|
182
|
+
*/
|
|
183
|
+
declare class TypedOperations {
|
|
184
|
+
private client;
|
|
185
|
+
constructor(client: ApitoClient);
|
|
186
|
+
private static toTypedDocument;
|
|
187
|
+
/**
|
|
188
|
+
* Get a single resource with type safety
|
|
189
|
+
*/
|
|
190
|
+
getSingleResourceTyped<T>(model: string, id: string, singlePageData?: boolean): Promise<TypedDocumentStructure<T>>;
|
|
191
|
+
/**
|
|
192
|
+
* Search resources with type safety
|
|
193
|
+
*/
|
|
194
|
+
searchResourcesTyped<T>(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<TypedSearchResult<T>>;
|
|
195
|
+
/**
|
|
196
|
+
* Get related documents with type safety
|
|
197
|
+
*/
|
|
198
|
+
getRelationDocumentsTyped<T>(id: string, connection: Record<string, any>): Promise<TypedSearchResult<T>>;
|
|
199
|
+
/**
|
|
200
|
+
* Create a new resource with type safety
|
|
201
|
+
*/
|
|
202
|
+
createNewResourceTyped<T>(request: CreateAndUpdateRequest): Promise<TypedDocumentStructure<T>>;
|
|
203
|
+
/**
|
|
204
|
+
* Update a resource with type safety
|
|
205
|
+
*/
|
|
206
|
+
updateResourceTyped<T>(request: CreateAndUpdateRequest): Promise<TypedDocumentStructure<T>>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Apito JavaScript internal SDK version (kept in sync with package.json for releases)
|
|
211
|
+
*/
|
|
212
|
+
declare const Version = "2.0.0";
|
|
213
|
+
/**
|
|
214
|
+
* GetVersion returns the current version of the SDK
|
|
215
|
+
*/
|
|
216
|
+
declare function getVersion(): string;
|
|
217
|
+
|
|
218
|
+
export { ApitoClient, ApitoError, type ClientConfig, type ConnectionOptions, type CreateAndUpdateRequest, type DefaultDocumentStructure, type Filter, GraphQLError, type GraphQLErrorLocation, type GraphQLResponse, type InjectedDBOperationInterface, type MetaField, type RequestOptions, type SearchOptions, type SearchResult, type TypedDocumentStructure, TypedOperations, type TypedSearchResult, ValidationError, Version, createClient, ApitoClient as default, getVersion };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @apito-io/js-admin-sdk - Admin SDK for Apito GraphQL API
|
|
2
|
+
var f=Object.create;var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)p(n,t,{get:e[t],enumerable:!0})},y=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of D(e))!S.call(n,a)&&a!==t&&p(n,a,{get:()=>e[a],enumerable:!(r=R(e,a))||r.enumerable});return n};var x=(n,e,t)=>(t=n!=null?f(T(n)):{},y(e||!n||!n.__esModule?p(t,"default",{value:n,enumerable:!0}):t,n)),b=n=>y(p({},"__esModule",{value:!0}),n);var w={};$(w,{ApitoClient:()=>c,ApitoError:()=>d,GraphQLError:()=>u,TypedOperations:()=>l,ValidationError:()=>s,Version:()=>m,createClient:()=>h,default:()=>c,getVersion:()=>_});module.exports=b(w);var g=x(require("axios"));var d=class extends Error{constructor(t,r,a,o){super(t);this.code=r;this.statusCode=a;this.details=o;this.name="ApitoError"}},u=class extends d{constructor(t,r,a){super(t,"GRAPHQL_ERROR");this.graphQLErrors=r;this.response=a;this.name="GraphQLError"}get partialData(){return this.response?.data}},s=class extends d{constructor(t,r){super(t,"VALIDATION_ERROR");this.field=r;this.name="ValidationError"}};var c=class{constructor(e){this.baseURL=e.baseURL,this.apiKey=e.apiKey,this.tenantId=e.tenantId,this.httpClient=g.default.create({timeout:e.timeout||3e4,headers:{"Content-Type":"application/json","X-Apito-Key":this.apiKey},...e.httpClient}),this.tenantId&&(this.httpClient.defaults.headers["X-Apito-Tenant-ID"]=this.tenantId)}async executeGraphQL(e,t,r){try{let a={query:e,variables:t||{}},o={"Content-Type":"application/json","X-Apito-Key":this.apiKey};(r?.tenantId||this.tenantId)&&(o["X-Apito-Tenant-ID"]=r?.tenantId||this.tenantId);let i=await this.httpClient.post(this.baseURL,a,{headers:o});if(i.data.errors&&i.data.errors.length>0)throw new u("GraphQL query failed",i.data.errors,i.data);return i.data}catch(a){throw g.default.isAxiosError(a)?new d(a.response?.data?.message||a.message,"HTTP_ERROR",a.response?.status,a.response?.data):a}}async generateTenantToken(e,t){let r=`
|
|
3
|
+
mutation GenerateTenantToken($token: String!, $tenantId: String!) {
|
|
4
|
+
generateTenantToken(token: $token, tenant_id: $tenantId) {
|
|
5
|
+
token
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`,a={token:e,tenantId:t},i=(await this.executeGraphQL(r,a,{tenantId:t})).data?.generateTenantToken;if(!i?.token)throw new s("Invalid response format for tenant token");return i.token}async getSingleResource(e,t,r=!1){let a=`
|
|
9
|
+
query GetSingleData($model: String, $_id: String!, $single_page_data: Boolean) {
|
|
10
|
+
getSingleData(model: $model, _id: $_id, single_page_data: $single_page_data) {
|
|
11
|
+
_key
|
|
12
|
+
data
|
|
13
|
+
meta {
|
|
14
|
+
created_at
|
|
15
|
+
updated_at
|
|
16
|
+
status
|
|
17
|
+
revision
|
|
18
|
+
revision_at
|
|
19
|
+
}
|
|
20
|
+
id
|
|
21
|
+
expire_at
|
|
22
|
+
relation_doc_id
|
|
23
|
+
type
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`,o={model:e,_id:t,single_page_data:r},i=await this.executeGraphQL(a,o);if(!i.data?.getSingleData)throw new s("Resource not found");return i.data.getSingleData}async searchResources(e,t={},r=!1){let a=`
|
|
27
|
+
query GetModelData(
|
|
28
|
+
$model: String!
|
|
29
|
+
$page: Int
|
|
30
|
+
$limit: Int
|
|
31
|
+
$_key: JSON
|
|
32
|
+
$where: JSON
|
|
33
|
+
$search: String
|
|
34
|
+
) {
|
|
35
|
+
getModelData(
|
|
36
|
+
model: $model
|
|
37
|
+
page: $page
|
|
38
|
+
limit: $limit
|
|
39
|
+
_key: $_key
|
|
40
|
+
where: $where
|
|
41
|
+
search: $search
|
|
42
|
+
) {
|
|
43
|
+
results {
|
|
44
|
+
id
|
|
45
|
+
relation_doc_id
|
|
46
|
+
data
|
|
47
|
+
type
|
|
48
|
+
expire_at
|
|
49
|
+
meta {
|
|
50
|
+
created_at
|
|
51
|
+
updated_at
|
|
52
|
+
status
|
|
53
|
+
root_revision_id
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
count
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`,o={model:e};t&&typeof t=="object"&&(t._key!==void 0&&(o._key=t._key),t.page!==void 0&&(o.page=t.page),t.limit!==void 0&&(o.limit=t.limit),t.where!==void 0&&(o.where=t.where),t.search!==void 0&&(o.search=t.search));let i=await this.executeGraphQL(a,o);if(!i.data?.getModelData)throw new s("Invalid search response format");return i.data.getModelData}async getRelationDocuments(e,t){let r=`
|
|
60
|
+
query GetModelData($model: String!, $page: Int, $limit: Int, $where: JSON, $search: String, $connection : ListAllDataDetailedOfAModelConnectionPayload) {
|
|
61
|
+
getModelData(model: $model, page: $page, limit: $limit, where: $where, search: $search, connection: $connection) {
|
|
62
|
+
results {
|
|
63
|
+
id
|
|
64
|
+
relation_doc_id
|
|
65
|
+
data
|
|
66
|
+
type
|
|
67
|
+
expire_at
|
|
68
|
+
meta {
|
|
69
|
+
created_at
|
|
70
|
+
updated_at
|
|
71
|
+
status
|
|
72
|
+
root_revision_id
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
count
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`,a={connection:t};if(t.model)a.model=t.model;else throw new s("model is required in connection parameters");if(t.filter){let i=t.filter;i.page!==void 0&&(a.page=i.page),i.limit!==void 0&&(a.limit=i.limit),i.where!==void 0&&(a.where=i.where),i.search!==void 0&&(a.search=i.search)}let o=await this.executeGraphQL(r,a);if(!o.data?.getModelData)throw new s("Invalid relation documents response format");return o.data.getModelData}async createNewResource(e){if(!e.model)throw new s("model is required");if(!e.payload)throw new s("payload is required");let t=`
|
|
79
|
+
mutation CreateNewData($model: String!, $single_page_data: Boolean, $payload: JSON!, $connect: JSON) {
|
|
80
|
+
upsertModelData(
|
|
81
|
+
connect: $connect
|
|
82
|
+
model_name: $model
|
|
83
|
+
single_page_data: $single_page_data
|
|
84
|
+
payload: $payload
|
|
85
|
+
) {
|
|
86
|
+
id
|
|
87
|
+
type
|
|
88
|
+
data
|
|
89
|
+
meta {
|
|
90
|
+
created_at
|
|
91
|
+
updated_at
|
|
92
|
+
status
|
|
93
|
+
revision
|
|
94
|
+
revision_at
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`,r={model:e.model,payload:e.payload,single_page_data:e.singlePageData||!1};e.connect&&(r.connect=e.connect);let a=await this.executeGraphQL(t,r);if(!a.data?.upsertModelData)throw new s("Invalid create response format");return a.data.upsertModelData}async updateResource(e){if(!e.id)throw new s("id is required");if(!e.model)throw new s("model is required");if(!e.payload)throw new s("payload is required");let t=`
|
|
99
|
+
mutation UpdateModelData($_id: String!, $model: String!, $single_page_data: Boolean, $force_update: Boolean, $payload: JSON!, $connect: JSON, $disconnect: JSON) {
|
|
100
|
+
upsertModelData(
|
|
101
|
+
connect: $connect
|
|
102
|
+
model_name: $model
|
|
103
|
+
single_page_data: $single_page_data
|
|
104
|
+
force_update: $force_update
|
|
105
|
+
disconnect: $disconnect
|
|
106
|
+
_id: $_id
|
|
107
|
+
payload: $payload
|
|
108
|
+
) {
|
|
109
|
+
id
|
|
110
|
+
type
|
|
111
|
+
data
|
|
112
|
+
meta {
|
|
113
|
+
created_at
|
|
114
|
+
updated_at
|
|
115
|
+
status
|
|
116
|
+
revision
|
|
117
|
+
revision_at
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`,r={_id:e.id,model:e.model,payload:e.payload,single_page_data:e.singlePageData||!1,force_update:e.forceUpdate||!1};e.connect&&(r.connect=e.connect),e.disconnect&&(r.disconnect=e.disconnect);let a=await this.executeGraphQL(t,r);if(!a.data?.upsertModelData)throw new s("Invalid update response format");return a.data.upsertModelData}async deleteResource(e,t){let r=`
|
|
122
|
+
mutation DeleteData($model: String!, $_id: String!) {
|
|
123
|
+
deleteModelData(model_name: $model, _id: $_id) {
|
|
124
|
+
id
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`,a={model:e,_id:t};await this.executeGraphQL(r,a)}async debug(e,...t){let r=`
|
|
128
|
+
mutation Debug($stage: String!, $data: JSON) {
|
|
129
|
+
debug(stage: $stage, data: $data) {
|
|
130
|
+
message
|
|
131
|
+
data
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`,a={stage:e,data:t};return(await this.executeGraphQL(r,a)).data?.debug}};function h(n){return new c(n)}var l=class n{constructor(e){this.client=e}static toTypedDocument(e){let t=JSON.parse(JSON.stringify(e.data));return{_key:e._key,_id:e._id,data:t,meta:e.meta,id:e.id,expire_at:e.expire_at,relation_doc_id:e.relation_doc_id,last_revision_doc_id:e.last_revision_doc_id,type:e.type,tenant_id:e.tenant_id,tenant_model:e.tenant_model}}async getSingleResourceTyped(e,t,r=!1){let a=await this.client.getSingleResource(e,t,r);return n.toTypedDocument(a)}async searchResourcesTyped(e,t={},r=!1){let a=await this.client.searchResources(e,t,r);return{results:a.results.map(o=>n.toTypedDocument(o)),count:a.count}}async getRelationDocumentsTyped(e,t){let r=await this.client.getRelationDocuments(e,t);return{results:r.results.map(a=>n.toTypedDocument(a)),count:r.count}}async createNewResourceTyped(e){let t=await this.client.createNewResource(e);return n.toTypedDocument(t)}async updateResourceTyped(e){let t=await this.client.updateResource(e);return n.toTypedDocument(t)}};var m="2.0.0";function _(){return m}0&&(module.exports={ApitoClient,ApitoError,GraphQLError,TypedOperations,ValidationError,Version,createClient,getVersion});
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/types.ts","../src/typed-operations.ts","../src/version.ts"],"sourcesContent":["/**\n * Apito JavaScript SDK\n * A comprehensive JavaScript SDK for communicating with Apito GraphQL API endpoints\n * \n * @module @apito-io/js-admin-sdk\n */\n\n// Export main client and types\nexport { ApitoClient, createClient } from './client';\nexport { TypedOperations } from './typed-operations';\nexport { Version, getVersion } from './version';\nexport * from './types';\n\n// Re-export commonly used types for convenience\nexport type {\n ClientConfig,\n DefaultDocumentStructure,\n SearchResult,\n TypedDocumentStructure,\n TypedSearchResult,\n CreateAndUpdateRequest,\n GraphQLResponse,\n GraphQLError,\n ApitoError,\n ValidationError,\n InjectedDBOperationInterface,\n} from './types';\n\n// Default export for convenience\nexport { ApitoClient as default } from './client';\n","import axios, { AxiosInstance } from 'axios';\nimport {\n ClientConfig,\n DefaultDocumentStructure,\n SearchResult,\n TypedDocumentStructure,\n TypedSearchResult,\n CreateAndUpdateRequest,\n GraphQLResponse,\n GraphQLError as SDKGraphQLError,\n ApitoError,\n ValidationError,\n InjectedDBOperationInterface,\n} from './types';\n\n/**\n * Apito SDK Client - JavaScript implementation matching the Go SDK\n */\nexport class ApitoClient implements InjectedDBOperationInterface {\n private httpClient: AxiosInstance;\n private baseURL: string;\n private apiKey: string;\n private tenantId?: string;\n\n constructor(config: ClientConfig) {\n this.baseURL = config.baseURL;\n this.apiKey = config.apiKey;\n this.tenantId = config.tenantId;\n\n // Create axios instance with default configuration\n this.httpClient = axios.create({\n timeout: config.timeout || 30000,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Apito-Key': this.apiKey,\n },\n ...config.httpClient,\n });\n\n // Add tenant ID to headers if provided\n if (this.tenantId) {\n this.httpClient.defaults.headers['X-Apito-Tenant-ID'] = this.tenantId;\n }\n }\n\n /**\n * Execute a GraphQL query or mutation\n */\n private async executeGraphQL<T = any>(\n query: string,\n variables?: Record<string, any>,\n options?: { tenantId?: string }\n ): Promise<GraphQLResponse> {\n try {\n const payload = {\n query,\n variables: variables || {},\n };\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Apito-Key': this.apiKey,\n };\n\n if (options?.tenantId || this.tenantId) {\n headers['X-Apito-Tenant-ID'] = options?.tenantId || this.tenantId!;\n }\n\n const response = await this.httpClient.post<GraphQLResponse>(\n this.baseURL,\n payload,\n { headers }\n );\n\n if (response.data.errors && response.data.errors.length > 0) {\n throw new SDKGraphQLError(\n 'GraphQL query failed',\n response.data.errors,\n response.data\n );\n }\n\n return response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new ApitoError(\n error.response?.data?.message || error.message,\n 'HTTP_ERROR',\n error.response?.status,\n error.response?.data\n );\n }\n throw error;\n }\n }\n\n /**\n * Generate a new tenant token for the specified tenant ID\n */\n async generateTenantToken(token: string, tenantId: string): Promise<string> {\n const query = `\n mutation GenerateTenantToken($token: String!, $tenantId: String!) {\n generateTenantToken(token: $token, tenant_id: $tenantId) {\n token\n }\n }\n `;\n\n const variables = { token, tenantId };\n const response = await this.executeGraphQL(query, variables, { tenantId });\n\n const data = response.data?.generateTenantToken;\n if (!data?.token) {\n throw new ValidationError('Invalid response format for tenant token');\n }\n\n return data.token;\n }\n\n /**\n * Get a single resource by model and ID\n */\n async getSingleResource(\n model: string,\n id: string,\n singlePageData: boolean = false\n ): Promise<DefaultDocumentStructure> {\n const query = `\n query GetSingleData($model: String, $_id: String!, $single_page_data: Boolean) {\n getSingleData(model: $model, _id: $_id, single_page_data: $single_page_data) {\n _key\n data\n meta {\n created_at\n updated_at\n status\n revision\n revision_at\n }\n id\n expire_at\n relation_doc_id\n type\n }\n }\n `;\n\n const variables = {\n model,\n _id: id,\n single_page_data: singlePageData,\n };\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.getSingleData) {\n throw new ValidationError('Resource not found');\n }\n\n return response.data.getSingleData;\n }\n\n /**\n * Search resources in a model\n */\n async searchResources(\n model: string,\n filter: Record<string, any> = {},\n aggregate: boolean = false\n ): Promise<SearchResult> {\n const query = `\n query GetModelData(\n $model: String!\n $page: Int\n $limit: Int\n $_key: JSON\n $where: JSON\n $search: String\n ) {\n getModelData(\n model: $model\n page: $page\n limit: $limit\n _key: $_key\n where: $where\n search: $search\n ) {\n results {\n id\n relation_doc_id\n data\n type\n expire_at\n meta {\n created_at\n updated_at\n status\n root_revision_id\n }\n }\n count\n }\n }\n `;\n\n // Only forward keys declared on the GraphQL operation (matches go-internal-sdk)\n const variables: Record<string, any> = { model };\n if (filter && typeof filter === 'object') {\n if (filter._key !== undefined) {\n variables._key = filter._key;\n }\n if (filter.page !== undefined) {\n variables.page = filter.page;\n }\n if (filter.limit !== undefined) {\n variables.limit = filter.limit;\n }\n if (filter.where !== undefined) {\n variables.where = filter.where;\n }\n if (filter.search !== undefined) {\n variables.search = filter.search;\n }\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.getModelData) {\n throw new ValidationError('Invalid search response format');\n }\n\n return response.data.getModelData;\n }\n\n /**\n * Get related documents\n */\n async getRelationDocuments(\n id: string,\n connection: Record<string, any>\n ): Promise<SearchResult> {\n const query = `\n query GetModelData($model: String!, $page: Int, $limit: Int, $where: JSON, $search: String, $connection : ListAllDataDetailedOfAModelConnectionPayload) {\n getModelData(model: $model, page: $page, limit: $limit, where: $where, search: $search, connection: $connection) {\n results {\n id\n relation_doc_id\n data\n type\n expire_at\n meta {\n created_at\n updated_at\n status\n root_revision_id\n }\n }\n count\n }\n }\n `;\n\n const variables: Record<string, any> = {\n connection,\n };\n\n // Extract model from connection if available\n if (connection.model) {\n variables.model = connection.model;\n } else {\n throw new ValidationError('model is required in connection parameters');\n }\n\n // Add filter parameters if provided in connection\n if (connection.filter) {\n const filter = connection.filter;\n if (filter.page !== undefined) {\n variables.page = filter.page;\n }\n if (filter.limit !== undefined) {\n variables.limit = filter.limit;\n }\n if (filter.where !== undefined) {\n variables.where = filter.where;\n }\n if (filter.search !== undefined) {\n variables.search = filter.search;\n }\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.getModelData) {\n throw new ValidationError('Invalid relation documents response format');\n }\n\n return response.data.getModelData;\n }\n\n /**\n * Create a new resource\n */\n async createNewResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure> {\n if (!request.model) {\n throw new ValidationError('model is required');\n }\n\n if (!request.payload) {\n throw new ValidationError('payload is required');\n }\n\n const query = `\n mutation CreateNewData($model: String!, $single_page_data: Boolean, $payload: JSON!, $connect: JSON) {\n upsertModelData(\n connect: $connect\n model_name: $model\n single_page_data: $single_page_data\n payload: $payload\n ) {\n id\n type\n data\n meta {\n created_at\n updated_at\n status\n revision\n revision_at\n }\n }\n }\n `;\n\n const variables: Record<string, any> = {\n model: request.model,\n payload: request.payload,\n single_page_data: request.singlePageData || false,\n };\n\n if (request.connect) {\n variables.connect = request.connect;\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.upsertModelData) {\n throw new ValidationError('Invalid create response format');\n }\n\n return response.data.upsertModelData;\n }\n\n /**\n * Update an existing resource\n */\n async updateResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure> {\n if (!request.id) {\n throw new ValidationError('id is required');\n }\n\n if (!request.model) {\n throw new ValidationError('model is required');\n }\n\n if (!request.payload) {\n throw new ValidationError('payload is required');\n }\n\n const query = `\n mutation UpdateModelData($_id: String!, $model: String!, $single_page_data: Boolean, $force_update: Boolean, $payload: JSON!, $connect: JSON, $disconnect: JSON) {\n upsertModelData(\n connect: $connect\n model_name: $model\n single_page_data: $single_page_data\n force_update: $force_update\n disconnect: $disconnect\n _id: $_id\n payload: $payload\n ) {\n id\n type\n data\n meta {\n created_at\n updated_at\n status\n revision\n revision_at\n }\n }\n }\n `;\n\n const variables: Record<string, any> = {\n _id: request.id,\n model: request.model,\n payload: request.payload,\n single_page_data: request.singlePageData || false,\n force_update: request.forceUpdate || false,\n };\n\n if (request.connect) {\n variables.connect = request.connect;\n }\n if (request.disconnect) {\n variables.disconnect = request.disconnect;\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.upsertModelData) {\n throw new ValidationError('Invalid update response format');\n }\n\n return response.data.upsertModelData;\n }\n\n /**\n * Delete a resource by model and ID\n */\n async deleteResource(model: string, id: string): Promise<void> {\n const query = `\n mutation DeleteData($model: String!, $_id: String!) {\n deleteModelData(model_name: $model, _id: $_id) {\n id\n }\n }\n `;\n\n const variables = {\n model,\n _id: id,\n };\n\n await this.executeGraphQL(query, variables);\n }\n\n /**\n * Debug is used to debug the plugin, you can pass data here to debug the plugin\n */\n async debug(stage: string, ...data: any[]): Promise<any> {\n const query = `\n mutation Debug($stage: String!, $data: JSON) {\n debug(stage: $stage, data: $data) {\n message\n data\n }\n }\n `;\n\n const variables = {\n stage,\n data,\n };\n\n const response = await this.executeGraphQL(query, variables);\n\n return response.data?.debug;\n }\n}\n\n/**\n * Factory function to create a new Apito client\n */\nexport function createClient(config: ClientConfig): ApitoClient {\n return new ApitoClient(config);\n}\n","/**\n * Type definitions for the Apito JavaScript SDK\n */\n\nexport interface MetaField {\n created_at: string;\n updated_at: string;\n status: string;\n revision?: string;\n revision_at?: string;\n root_revision_id?: string;\n}\n\nexport interface DefaultDocumentStructure {\n _key?: string;\n _id?: string;\n data: any;\n meta?: MetaField;\n id: string;\n expire_at?: string | number;\n relation_doc_id?: string;\n last_revision_doc_id?: string;\n type?: string;\n tenant_id?: string;\n tenant_model?: string;\n}\n\nexport interface SearchResult {\n results: DefaultDocumentStructure[];\n count: number;\n}\n\nexport interface TypedDocumentStructure<T> {\n _key?: string;\n _id?: string;\n data: T;\n meta?: MetaField;\n id: string;\n expire_at?: string | number;\n relation_doc_id?: string;\n last_revision_doc_id?: string;\n type?: string;\n tenant_id?: string;\n tenant_model?: string;\n}\n\nexport interface TypedSearchResult<T> {\n results: TypedDocumentStructure<T>[];\n count: number;\n}\n\nexport interface Filter {\n page?: number;\n offset?: number;\n limit?: number;\n order?: string;\n min?: number;\n max?: number;\n category?: string;\n}\n\nexport interface GraphQLErrorLocation {\n line: number;\n column: number;\n}\n\nexport interface GraphQLError {\n message: string;\n locations?: GraphQLErrorLocation[];\n path?: (string | number)[];\n extensions?: Record<string, any>;\n}\n\nexport interface GraphQLResponse {\n data?: any;\n errors?: GraphQLError[];\n}\n\nexport interface CreateAndUpdateRequest {\n id?: string;\n model: string;\n payload: any;\n connect?: Record<string, any>;\n disconnect?: Record<string, any>;\n singlePageData?: boolean;\n forceUpdate?: boolean;\n}\n\nexport interface ClientConfig {\n baseURL: string;\n apiKey: string;\n timeout?: number;\n httpClient?: any;\n tenantId?: string;\n}\n\nexport interface RequestOptions {\n headers?: Record<string, string>;\n timeout?: number;\n}\n\nexport interface SearchOptions {\n limit?: number;\n page?: number;\n offset?: number;\n where?: Record<string, any>;\n search?: string;\n sort?: Record<string, 1 | -1>;\n}\n\nexport interface ConnectionOptions {\n model: string;\n filter?: SearchOptions;\n}\n\n// Plugin interface matching the Go SDK\nexport interface InjectedDBOperationInterface {\n generateTenantToken(token: string, tenantId: string): Promise<string>;\n getSingleResource(model: string, id: string, singlePageData?: boolean): Promise<DefaultDocumentStructure>;\n searchResources(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<SearchResult>;\n getRelationDocuments(id: string, connection: Record<string, any>): Promise<SearchResult>;\n createNewResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;\n updateResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;\n deleteResource(model: string, id: string): Promise<void>;\n debug(stage: string, ...data: any[]): Promise<any>;\n}\n\n// Typed operations interface\nexport interface TypedOperations {\n getSingleResourceTyped<T>(model: string, id: string, singlePageData?: boolean): Promise<TypedDocumentStructure<T>>;\n searchResourcesTyped<T>(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<TypedSearchResult<T>>;\n getRelationDocumentsTyped<T>(id: string, connection: Record<string, any>): Promise<TypedSearchResult<T>>;\n createNewResourceTyped<T>(request: CreateAndUpdateRequest): Promise<TypedDocumentStructure<T>>;\n updateResourceTyped<T>(request: CreateAndUpdateRequest): Promise<TypedDocumentStructure<T>>;\n}\n\n// Error classes\nexport class ApitoError extends Error {\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: any\n ) {\n super(message);\n this.name = 'ApitoError';\n }\n}\n\nexport class GraphQLError extends ApitoError {\n constructor(\n message: string,\n public graphQLErrors: GraphQLError[],\n public response?: any\n ) {\n super(message, 'GRAPHQL_ERROR');\n this.name = 'GraphQLError';\n }\n\n get partialData(): any {\n return this.response?.data;\n }\n}\n\nexport class ValidationError extends ApitoError {\n constructor(message: string, public field?: string) {\n super(message, 'VALIDATION_ERROR');\n this.name = 'ValidationError';\n }\n}\n","import {\n DefaultDocumentStructure,\n TypedDocumentStructure,\n TypedSearchResult,\n CreateAndUpdateRequest,\n} from './types';\nimport { ApitoClient } from './client';\n\n/**\n * Typed operations wrapper for the Apito SDK\n * Provides type-safe methods for working with typed data\n */\nexport class TypedOperations {\n constructor(private client: ApitoClient) {}\n\n private static toTypedDocument<T>(raw: DefaultDocumentStructure): TypedDocumentStructure<T> {\n const data = JSON.parse(JSON.stringify(raw.data)) as T;\n return {\n _key: raw._key,\n _id: raw._id,\n data,\n meta: raw.meta,\n id: raw.id,\n expire_at: raw.expire_at,\n relation_doc_id: raw.relation_doc_id,\n last_revision_doc_id: raw.last_revision_doc_id,\n type: raw.type,\n tenant_id: raw.tenant_id,\n tenant_model: raw.tenant_model,\n };\n }\n\n /**\n * Get a single resource with type safety\n */\n async getSingleResourceTyped<T>(\n model: string,\n id: string,\n singlePageData: boolean = false\n ): Promise<TypedDocumentStructure<T>> {\n const result = await this.client.getSingleResource(model, id, singlePageData);\n return TypedOperations.toTypedDocument<T>(result);\n }\n\n /**\n * Search resources with type safety\n */\n async searchResourcesTyped<T>(\n model: string,\n filter: Record<string, any> = {},\n aggregate: boolean = false\n ): Promise<TypedSearchResult<T>> {\n const result = await this.client.searchResources(model, filter, aggregate);\n return {\n results: result.results.map((doc) => TypedOperations.toTypedDocument<T>(doc)),\n count: result.count,\n };\n }\n\n /**\n * Get related documents with type safety\n */\n async getRelationDocumentsTyped<T>(\n id: string,\n connection: Record<string, any>\n ): Promise<TypedSearchResult<T>> {\n const result = await this.client.getRelationDocuments(id, connection);\n return {\n results: result.results.map((doc) => TypedOperations.toTypedDocument<T>(doc)),\n count: result.count,\n };\n }\n\n /**\n * Create a new resource with type safety\n */\n async createNewResourceTyped<T>(\n request: CreateAndUpdateRequest\n ): Promise<TypedDocumentStructure<T>> {\n const result = await this.client.createNewResource(request);\n return TypedOperations.toTypedDocument<T>(result);\n }\n\n /**\n * Update a resource with type safety\n */\n async updateResourceTyped<T>(\n request: CreateAndUpdateRequest\n ): Promise<TypedDocumentStructure<T>> {\n const result = await this.client.updateResource(request);\n return TypedOperations.toTypedDocument<T>(result);\n }\n}\n","/**\n * Apito JavaScript internal SDK version (kept in sync with package.json for releases)\n */\nexport const Version = '2.0.0';\n\n/**\n * GetVersion returns the current version of the SDK\n */\nexport function getVersion(): string {\n return Version;\n}\n"],"mappings":";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,YAAAC,EAAA,iBAAAC,EAAA,YAAAN,EAAA,eAAAO,IAAA,eAAAC,EAAAV,GCAA,IAAAW,EAAqC,oBCyI9B,IAAMC,EAAN,cAAyB,KAAM,CACpC,YACEC,EACOC,EACAC,EACAC,EACP,CACA,MAAMH,CAAO,EAJN,UAAAC,EACA,gBAAAC,EACA,aAAAC,EAGP,KAAK,KAAO,YACd,CACF,EAEaC,EAAN,cAA2BL,CAAW,CAC3C,YACEC,EACOK,EACAC,EACP,CACA,MAAMN,EAAS,eAAe,EAHvB,mBAAAK,EACA,cAAAC,EAGP,KAAK,KAAO,cACd,CAEA,IAAI,aAAmB,CACrB,OAAO,KAAK,UAAU,IACxB,CACF,EAEaC,EAAN,cAA8BR,CAAW,CAC9C,YAAYC,EAAwBQ,EAAgB,CAClD,MAAMR,E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O,IAAMM,EAAU,QAKhB,SAASC,GAAqB,CACjC,OAAOD,CACX","names":["index_exports","__export","ApitoClient","ApitoError","GraphQLError","TypedOperations","ValidationError","Version","createClient","getVersion","__toCommonJS","import_axios","ApitoError","message","code","statusCode","details","GraphQLError","graphQLErrors","response","ValidationError","field","ApitoClient","config","axios","query","variables","options","payload","headers","response","GraphQLError","error","ApitoError","token","tenantId","data","ValidationError","model","id","singlePageData","filter","aggregate","connection","request","stage","createClient","TypedOperations","_TypedOperations","client","raw","data","model","id","singlePageData","result","filter","aggregate","doc","connection","request","Version","getVersion"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @apito-io/js-admin-sdk - Admin SDK for Apito GraphQL API
|
|
2
|
+
import l from"axios";var d=class extends Error{constructor(t,r,a,i){super(t);this.code=r;this.statusCode=a;this.details=i;this.name="ApitoError"}},u=class extends d{constructor(t,r,a){super(t,"GRAPHQL_ERROR");this.graphQLErrors=r;this.response=a;this.name="GraphQLError"}get partialData(){return this.response?.data}},o=class extends d{constructor(t,r){super(t,"VALIDATION_ERROR");this.field=r;this.name="ValidationError"}};var c=class{constructor(e){this.baseURL=e.baseURL,this.apiKey=e.apiKey,this.tenantId=e.tenantId,this.httpClient=l.create({timeout:e.timeout||3e4,headers:{"Content-Type":"application/json","X-Apito-Key":this.apiKey},...e.httpClient}),this.tenantId&&(this.httpClient.defaults.headers["X-Apito-Tenant-ID"]=this.tenantId)}async executeGraphQL(e,t,r){try{let a={query:e,variables:t||{}},i={"Content-Type":"application/json","X-Apito-Key":this.apiKey};(r?.tenantId||this.tenantId)&&(i["X-Apito-Tenant-ID"]=r?.tenantId||this.tenantId);let n=await this.httpClient.post(this.baseURL,a,{headers:i});if(n.data.errors&&n.data.errors.length>0)throw new u("GraphQL query failed",n.data.errors,n.data);return n.data}catch(a){throw l.isAxiosError(a)?new d(a.response?.data?.message||a.message,"HTTP_ERROR",a.response?.status,a.response?.data):a}}async generateTenantToken(e,t){let r=`
|
|
3
|
+
mutation GenerateTenantToken($token: String!, $tenantId: String!) {
|
|
4
|
+
generateTenantToken(token: $token, tenant_id: $tenantId) {
|
|
5
|
+
token
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`,a={token:e,tenantId:t},n=(await this.executeGraphQL(r,a,{tenantId:t})).data?.generateTenantToken;if(!n?.token)throw new o("Invalid response format for tenant token");return n.token}async getSingleResource(e,t,r=!1){let a=`
|
|
9
|
+
query GetSingleData($model: String, $_id: String!, $single_page_data: Boolean) {
|
|
10
|
+
getSingleData(model: $model, _id: $_id, single_page_data: $single_page_data) {
|
|
11
|
+
_key
|
|
12
|
+
data
|
|
13
|
+
meta {
|
|
14
|
+
created_at
|
|
15
|
+
updated_at
|
|
16
|
+
status
|
|
17
|
+
revision
|
|
18
|
+
revision_at
|
|
19
|
+
}
|
|
20
|
+
id
|
|
21
|
+
expire_at
|
|
22
|
+
relation_doc_id
|
|
23
|
+
type
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`,i={model:e,_id:t,single_page_data:r},n=await this.executeGraphQL(a,i);if(!n.data?.getSingleData)throw new o("Resource not found");return n.data.getSingleData}async searchResources(e,t={},r=!1){let a=`
|
|
27
|
+
query GetModelData(
|
|
28
|
+
$model: String!
|
|
29
|
+
$page: Int
|
|
30
|
+
$limit: Int
|
|
31
|
+
$_key: JSON
|
|
32
|
+
$where: JSON
|
|
33
|
+
$search: String
|
|
34
|
+
) {
|
|
35
|
+
getModelData(
|
|
36
|
+
model: $model
|
|
37
|
+
page: $page
|
|
38
|
+
limit: $limit
|
|
39
|
+
_key: $_key
|
|
40
|
+
where: $where
|
|
41
|
+
search: $search
|
|
42
|
+
) {
|
|
43
|
+
results {
|
|
44
|
+
id
|
|
45
|
+
relation_doc_id
|
|
46
|
+
data
|
|
47
|
+
type
|
|
48
|
+
expire_at
|
|
49
|
+
meta {
|
|
50
|
+
created_at
|
|
51
|
+
updated_at
|
|
52
|
+
status
|
|
53
|
+
root_revision_id
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
count
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`,i={model:e};t&&typeof t=="object"&&(t._key!==void 0&&(i._key=t._key),t.page!==void 0&&(i.page=t.page),t.limit!==void 0&&(i.limit=t.limit),t.where!==void 0&&(i.where=t.where),t.search!==void 0&&(i.search=t.search));let n=await this.executeGraphQL(a,i);if(!n.data?.getModelData)throw new o("Invalid search response format");return n.data.getModelData}async getRelationDocuments(e,t){let r=`
|
|
60
|
+
query GetModelData($model: String!, $page: Int, $limit: Int, $where: JSON, $search: String, $connection : ListAllDataDetailedOfAModelConnectionPayload) {
|
|
61
|
+
getModelData(model: $model, page: $page, limit: $limit, where: $where, search: $search, connection: $connection) {
|
|
62
|
+
results {
|
|
63
|
+
id
|
|
64
|
+
relation_doc_id
|
|
65
|
+
data
|
|
66
|
+
type
|
|
67
|
+
expire_at
|
|
68
|
+
meta {
|
|
69
|
+
created_at
|
|
70
|
+
updated_at
|
|
71
|
+
status
|
|
72
|
+
root_revision_id
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
count
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`,a={connection:t};if(t.model)a.model=t.model;else throw new o("model is required in connection parameters");if(t.filter){let n=t.filter;n.page!==void 0&&(a.page=n.page),n.limit!==void 0&&(a.limit=n.limit),n.where!==void 0&&(a.where=n.where),n.search!==void 0&&(a.search=n.search)}let i=await this.executeGraphQL(r,a);if(!i.data?.getModelData)throw new o("Invalid relation documents response format");return i.data.getModelData}async createNewResource(e){if(!e.model)throw new o("model is required");if(!e.payload)throw new o("payload is required");let t=`
|
|
79
|
+
mutation CreateNewData($model: String!, $single_page_data: Boolean, $payload: JSON!, $connect: JSON) {
|
|
80
|
+
upsertModelData(
|
|
81
|
+
connect: $connect
|
|
82
|
+
model_name: $model
|
|
83
|
+
single_page_data: $single_page_data
|
|
84
|
+
payload: $payload
|
|
85
|
+
) {
|
|
86
|
+
id
|
|
87
|
+
type
|
|
88
|
+
data
|
|
89
|
+
meta {
|
|
90
|
+
created_at
|
|
91
|
+
updated_at
|
|
92
|
+
status
|
|
93
|
+
revision
|
|
94
|
+
revision_at
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`,r={model:e.model,payload:e.payload,single_page_data:e.singlePageData||!1};e.connect&&(r.connect=e.connect);let a=await this.executeGraphQL(t,r);if(!a.data?.upsertModelData)throw new o("Invalid create response format");return a.data.upsertModelData}async updateResource(e){if(!e.id)throw new o("id is required");if(!e.model)throw new o("model is required");if(!e.payload)throw new o("payload is required");let t=`
|
|
99
|
+
mutation UpdateModelData($_id: String!, $model: String!, $single_page_data: Boolean, $force_update: Boolean, $payload: JSON!, $connect: JSON, $disconnect: JSON) {
|
|
100
|
+
upsertModelData(
|
|
101
|
+
connect: $connect
|
|
102
|
+
model_name: $model
|
|
103
|
+
single_page_data: $single_page_data
|
|
104
|
+
force_update: $force_update
|
|
105
|
+
disconnect: $disconnect
|
|
106
|
+
_id: $_id
|
|
107
|
+
payload: $payload
|
|
108
|
+
) {
|
|
109
|
+
id
|
|
110
|
+
type
|
|
111
|
+
data
|
|
112
|
+
meta {
|
|
113
|
+
created_at
|
|
114
|
+
updated_at
|
|
115
|
+
status
|
|
116
|
+
revision
|
|
117
|
+
revision_at
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`,r={_id:e.id,model:e.model,payload:e.payload,single_page_data:e.singlePageData||!1,force_update:e.forceUpdate||!1};e.connect&&(r.connect=e.connect),e.disconnect&&(r.disconnect=e.disconnect);let a=await this.executeGraphQL(t,r);if(!a.data?.upsertModelData)throw new o("Invalid update response format");return a.data.upsertModelData}async deleteResource(e,t){let r=`
|
|
122
|
+
mutation DeleteData($model: String!, $_id: String!) {
|
|
123
|
+
deleteModelData(model_name: $model, _id: $_id) {
|
|
124
|
+
id
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`,a={model:e,_id:t};await this.executeGraphQL(r,a)}async debug(e,...t){let r=`
|
|
128
|
+
mutation Debug($stage: String!, $data: JSON) {
|
|
129
|
+
debug(stage: $stage, data: $data) {
|
|
130
|
+
message
|
|
131
|
+
data
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`,a={stage:e,data:t};return(await this.executeGraphQL(r,a)).data?.debug}};function m(s){return new c(s)}var p=class s{constructor(e){this.client=e}static toTypedDocument(e){let t=JSON.parse(JSON.stringify(e.data));return{_key:e._key,_id:e._id,data:t,meta:e.meta,id:e.id,expire_at:e.expire_at,relation_doc_id:e.relation_doc_id,last_revision_doc_id:e.last_revision_doc_id,type:e.type,tenant_id:e.tenant_id,tenant_model:e.tenant_model}}async getSingleResourceTyped(e,t,r=!1){let a=await this.client.getSingleResource(e,t,r);return s.toTypedDocument(a)}async searchResourcesTyped(e,t={},r=!1){let a=await this.client.searchResources(e,t,r);return{results:a.results.map(i=>s.toTypedDocument(i)),count:a.count}}async getRelationDocumentsTyped(e,t){let r=await this.client.getRelationDocuments(e,t);return{results:r.results.map(a=>s.toTypedDocument(a)),count:r.count}}async createNewResourceTyped(e){let t=await this.client.createNewResource(e);return s.toTypedDocument(t)}async updateResourceTyped(e){let t=await this.client.updateResource(e);return s.toTypedDocument(t)}};var g="2.0.0";function y(){return g}export{c as ApitoClient,d as ApitoError,u as GraphQLError,p as TypedOperations,o as ValidationError,g as Version,m as createClient,c as default,y as getVersion};
|
|
135
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/types.ts","../src/typed-operations.ts","../src/version.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport {\n ClientConfig,\n DefaultDocumentStructure,\n SearchResult,\n TypedDocumentStructure,\n TypedSearchResult,\n CreateAndUpdateRequest,\n GraphQLResponse,\n GraphQLError as SDKGraphQLError,\n ApitoError,\n ValidationError,\n InjectedDBOperationInterface,\n} from './types';\n\n/**\n * Apito SDK Client - JavaScript implementation matching the Go SDK\n */\nexport class ApitoClient implements InjectedDBOperationInterface {\n private httpClient: AxiosInstance;\n private baseURL: string;\n private apiKey: string;\n private tenantId?: string;\n\n constructor(config: ClientConfig) {\n this.baseURL = config.baseURL;\n this.apiKey = config.apiKey;\n this.tenantId = config.tenantId;\n\n // Create axios instance with default configuration\n this.httpClient = axios.create({\n timeout: config.timeout || 30000,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Apito-Key': this.apiKey,\n },\n ...config.httpClient,\n });\n\n // Add tenant ID to headers if provided\n if (this.tenantId) {\n this.httpClient.defaults.headers['X-Apito-Tenant-ID'] = this.tenantId;\n }\n }\n\n /**\n * Execute a GraphQL query or mutation\n */\n private async executeGraphQL<T = any>(\n query: string,\n variables?: Record<string, any>,\n options?: { tenantId?: string }\n ): Promise<GraphQLResponse> {\n try {\n const payload = {\n query,\n variables: variables || {},\n };\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Apito-Key': this.apiKey,\n };\n\n if (options?.tenantId || this.tenantId) {\n headers['X-Apito-Tenant-ID'] = options?.tenantId || this.tenantId!;\n }\n\n const response = await this.httpClient.post<GraphQLResponse>(\n this.baseURL,\n payload,\n { headers }\n );\n\n if (response.data.errors && response.data.errors.length > 0) {\n throw new SDKGraphQLError(\n 'GraphQL query failed',\n response.data.errors,\n response.data\n );\n }\n\n return response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new ApitoError(\n error.response?.data?.message || error.message,\n 'HTTP_ERROR',\n error.response?.status,\n error.response?.data\n );\n }\n throw error;\n }\n }\n\n /**\n * Generate a new tenant token for the specified tenant ID\n */\n async generateTenantToken(token: string, tenantId: string): Promise<string> {\n const query = `\n mutation GenerateTenantToken($token: String!, $tenantId: String!) {\n generateTenantToken(token: $token, tenant_id: $tenantId) {\n token\n }\n }\n `;\n\n const variables = { token, tenantId };\n const response = await this.executeGraphQL(query, variables, { tenantId });\n\n const data = response.data?.generateTenantToken;\n if (!data?.token) {\n throw new ValidationError('Invalid response format for tenant token');\n }\n\n return data.token;\n }\n\n /**\n * Get a single resource by model and ID\n */\n async getSingleResource(\n model: string,\n id: string,\n singlePageData: boolean = false\n ): Promise<DefaultDocumentStructure> {\n const query = `\n query GetSingleData($model: String, $_id: String!, $single_page_data: Boolean) {\n getSingleData(model: $model, _id: $_id, single_page_data: $single_page_data) {\n _key\n data\n meta {\n created_at\n updated_at\n status\n revision\n revision_at\n }\n id\n expire_at\n relation_doc_id\n type\n }\n }\n `;\n\n const variables = {\n model,\n _id: id,\n single_page_data: singlePageData,\n };\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.getSingleData) {\n throw new ValidationError('Resource not found');\n }\n\n return response.data.getSingleData;\n }\n\n /**\n * Search resources in a model\n */\n async searchResources(\n model: string,\n filter: Record<string, any> = {},\n aggregate: boolean = false\n ): Promise<SearchResult> {\n const query = `\n query GetModelData(\n $model: String!\n $page: Int\n $limit: Int\n $_key: JSON\n $where: JSON\n $search: String\n ) {\n getModelData(\n model: $model\n page: $page\n limit: $limit\n _key: $_key\n where: $where\n search: $search\n ) {\n results {\n id\n relation_doc_id\n data\n type\n expire_at\n meta {\n created_at\n updated_at\n status\n root_revision_id\n }\n }\n count\n }\n }\n `;\n\n // Only forward keys declared on the GraphQL operation (matches go-internal-sdk)\n const variables: Record<string, any> = { model };\n if (filter && typeof filter === 'object') {\n if (filter._key !== undefined) {\n variables._key = filter._key;\n }\n if (filter.page !== undefined) {\n variables.page = filter.page;\n }\n if (filter.limit !== undefined) {\n variables.limit = filter.limit;\n }\n if (filter.where !== undefined) {\n variables.where = filter.where;\n }\n if (filter.search !== undefined) {\n variables.search = filter.search;\n }\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.getModelData) {\n throw new ValidationError('Invalid search response format');\n }\n\n return response.data.getModelData;\n }\n\n /**\n * Get related documents\n */\n async getRelationDocuments(\n id: string,\n connection: Record<string, any>\n ): Promise<SearchResult> {\n const query = `\n query GetModelData($model: String!, $page: Int, $limit: Int, $where: JSON, $search: String, $connection : ListAllDataDetailedOfAModelConnectionPayload) {\n getModelData(model: $model, page: $page, limit: $limit, where: $where, search: $search, connection: $connection) {\n results {\n id\n relation_doc_id\n data\n type\n expire_at\n meta {\n created_at\n updated_at\n status\n root_revision_id\n }\n }\n count\n }\n }\n `;\n\n const variables: Record<string, any> = {\n connection,\n };\n\n // Extract model from connection if available\n if (connection.model) {\n variables.model = connection.model;\n } else {\n throw new ValidationError('model is required in connection parameters');\n }\n\n // Add filter parameters if provided in connection\n if (connection.filter) {\n const filter = connection.filter;\n if (filter.page !== undefined) {\n variables.page = filter.page;\n }\n if (filter.limit !== undefined) {\n variables.limit = filter.limit;\n }\n if (filter.where !== undefined) {\n variables.where = filter.where;\n }\n if (filter.search !== undefined) {\n variables.search = filter.search;\n }\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.getModelData) {\n throw new ValidationError('Invalid relation documents response format');\n }\n\n return response.data.getModelData;\n }\n\n /**\n * Create a new resource\n */\n async createNewResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure> {\n if (!request.model) {\n throw new ValidationError('model is required');\n }\n\n if (!request.payload) {\n throw new ValidationError('payload is required');\n }\n\n const query = `\n mutation CreateNewData($model: String!, $single_page_data: Boolean, $payload: JSON!, $connect: JSON) {\n upsertModelData(\n connect: $connect\n model_name: $model\n single_page_data: $single_page_data\n payload: $payload\n ) {\n id\n type\n data\n meta {\n created_at\n updated_at\n status\n revision\n revision_at\n }\n }\n }\n `;\n\n const variables: Record<string, any> = {\n model: request.model,\n payload: request.payload,\n single_page_data: request.singlePageData || false,\n };\n\n if (request.connect) {\n variables.connect = request.connect;\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.upsertModelData) {\n throw new ValidationError('Invalid create response format');\n }\n\n return response.data.upsertModelData;\n }\n\n /**\n * Update an existing resource\n */\n async updateResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure> {\n if (!request.id) {\n throw new ValidationError('id is required');\n }\n\n if (!request.model) {\n throw new ValidationError('model is required');\n }\n\n if (!request.payload) {\n throw new ValidationError('payload is required');\n }\n\n const query = `\n mutation UpdateModelData($_id: String!, $model: String!, $single_page_data: Boolean, $force_update: Boolean, $payload: JSON!, $connect: JSON, $disconnect: JSON) {\n upsertModelData(\n connect: $connect\n model_name: $model\n single_page_data: $single_page_data\n force_update: $force_update\n disconnect: $disconnect\n _id: $_id\n payload: $payload\n ) {\n id\n type\n data\n meta {\n created_at\n updated_at\n status\n revision\n revision_at\n }\n }\n }\n `;\n\n const variables: Record<string, any> = {\n _id: request.id,\n model: request.model,\n payload: request.payload,\n single_page_data: request.singlePageData || false,\n force_update: request.forceUpdate || false,\n };\n\n if (request.connect) {\n variables.connect = request.connect;\n }\n if (request.disconnect) {\n variables.disconnect = request.disconnect;\n }\n\n const response = await this.executeGraphQL(query, variables);\n\n if (!response.data?.upsertModelData) {\n throw new ValidationError('Invalid update response format');\n }\n\n return response.data.upsertModelData;\n }\n\n /**\n * Delete a resource by model and ID\n */\n async deleteResource(model: string, id: string): Promise<void> {\n const query = `\n mutation DeleteData($model: String!, $_id: String!) {\n deleteModelData(model_name: $model, _id: $_id) {\n id\n }\n }\n `;\n\n const variables = {\n model,\n _id: id,\n };\n\n await this.executeGraphQL(query, variables);\n }\n\n /**\n * Debug is used to debug the plugin, you can pass data here to debug the plugin\n */\n async debug(stage: string, ...data: any[]): Promise<any> {\n const query = `\n mutation Debug($stage: String!, $data: JSON) {\n debug(stage: $stage, data: $data) {\n message\n data\n }\n }\n `;\n\n const variables = {\n stage,\n data,\n };\n\n const response = await this.executeGraphQL(query, variables);\n\n return response.data?.debug;\n }\n}\n\n/**\n * Factory function to create a new Apito client\n */\nexport function createClient(config: ClientConfig): ApitoClient {\n return new ApitoClient(config);\n}\n","/**\n * Type definitions for the Apito JavaScript SDK\n */\n\nexport interface MetaField {\n created_at: string;\n updated_at: string;\n status: string;\n revision?: string;\n revision_at?: string;\n root_revision_id?: string;\n}\n\nexport interface DefaultDocumentStructure {\n _key?: string;\n _id?: string;\n data: any;\n meta?: MetaField;\n id: string;\n expire_at?: string | number;\n relation_doc_id?: string;\n last_revision_doc_id?: string;\n type?: string;\n tenant_id?: string;\n tenant_model?: string;\n}\n\nexport interface SearchResult {\n results: DefaultDocumentStructure[];\n count: number;\n}\n\nexport interface TypedDocumentStructure<T> {\n _key?: string;\n _id?: string;\n data: T;\n meta?: MetaField;\n id: string;\n expire_at?: string | number;\n relation_doc_id?: string;\n last_revision_doc_id?: string;\n type?: string;\n tenant_id?: string;\n tenant_model?: string;\n}\n\nexport interface TypedSearchResult<T> {\n results: TypedDocumentStructure<T>[];\n count: number;\n}\n\nexport interface Filter {\n page?: number;\n offset?: number;\n limit?: number;\n order?: string;\n min?: number;\n max?: number;\n category?: string;\n}\n\nexport interface GraphQLErrorLocation {\n line: number;\n column: number;\n}\n\nexport interface GraphQLError {\n message: string;\n locations?: GraphQLErrorLocation[];\n path?: (string | number)[];\n extensions?: Record<string, any>;\n}\n\nexport interface GraphQLResponse {\n data?: any;\n errors?: GraphQLError[];\n}\n\nexport interface CreateAndUpdateRequest {\n id?: string;\n model: string;\n payload: any;\n connect?: Record<string, any>;\n disconnect?: Record<string, any>;\n singlePageData?: boolean;\n forceUpdate?: boolean;\n}\n\nexport interface ClientConfig {\n baseURL: string;\n apiKey: string;\n timeout?: number;\n httpClient?: any;\n tenantId?: string;\n}\n\nexport interface RequestOptions {\n headers?: Record<string, string>;\n timeout?: number;\n}\n\nexport interface SearchOptions {\n limit?: number;\n page?: number;\n offset?: number;\n where?: Record<string, any>;\n search?: string;\n sort?: Record<string, 1 | -1>;\n}\n\nexport interface ConnectionOptions {\n model: string;\n filter?: SearchOptions;\n}\n\n// Plugin interface matching the Go SDK\nexport interface InjectedDBOperationInterface {\n generateTenantToken(token: string, tenantId: string): Promise<string>;\n getSingleResource(model: string, id: string, singlePageData?: boolean): Promise<DefaultDocumentStructure>;\n searchResources(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<SearchResult>;\n getRelationDocuments(id: string, connection: Record<string, any>): Promise<SearchResult>;\n createNewResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;\n updateResource(request: CreateAndUpdateRequest): Promise<DefaultDocumentStructure>;\n deleteResource(model: string, id: string): Promise<void>;\n debug(stage: string, ...data: any[]): Promise<any>;\n}\n\n// Typed operations interface\nexport interface TypedOperations {\n getSingleResourceTyped<T>(model: string, id: string, singlePageData?: boolean): Promise<TypedDocumentStructure<T>>;\n searchResourcesTyped<T>(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<TypedSearchResult<T>>;\n getRelationDocumentsTyped<T>(id: string, connection: Record<string, any>): Promise<TypedSearchResult<T>>;\n createNewResourceTyped<T>(request: CreateAndUpdateRequest): Promise<TypedDocumentStructure<T>>;\n updateResourceTyped<T>(request: CreateAndUpdateRequest): Promise<TypedDocumentStructure<T>>;\n}\n\n// Error classes\nexport class ApitoError extends Error {\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: any\n ) {\n super(message);\n this.name = 'ApitoError';\n }\n}\n\nexport class GraphQLError extends ApitoError {\n constructor(\n message: string,\n public graphQLErrors: GraphQLError[],\n public response?: any\n ) {\n super(message, 'GRAPHQL_ERROR');\n this.name = 'GraphQLError';\n }\n\n get partialData(): any {\n return this.response?.data;\n }\n}\n\nexport class ValidationError extends ApitoError {\n constructor(message: string, public field?: string) {\n super(message, 'VALIDATION_ERROR');\n this.name = 'ValidationError';\n }\n}\n","import {\n DefaultDocumentStructure,\n TypedDocumentStructure,\n TypedSearchResult,\n CreateAndUpdateRequest,\n} from './types';\nimport { ApitoClient } from './client';\n\n/**\n * Typed operations wrapper for the Apito SDK\n * Provides type-safe methods for working with typed data\n */\nexport class TypedOperations {\n constructor(private client: ApitoClient) {}\n\n private static toTypedDocument<T>(raw: DefaultDocumentStructure): TypedDocumentStructure<T> {\n const data = JSON.parse(JSON.stringify(raw.data)) as T;\n return {\n _key: raw._key,\n _id: raw._id,\n data,\n meta: raw.meta,\n id: raw.id,\n expire_at: raw.expire_at,\n relation_doc_id: raw.relation_doc_id,\n last_revision_doc_id: raw.last_revision_doc_id,\n type: raw.type,\n tenant_id: raw.tenant_id,\n tenant_model: raw.tenant_model,\n };\n }\n\n /**\n * Get a single resource with type safety\n */\n async getSingleResourceTyped<T>(\n model: string,\n id: string,\n singlePageData: boolean = false\n ): Promise<TypedDocumentStructure<T>> {\n const result = await this.client.getSingleResource(model, id, singlePageData);\n return TypedOperations.toTypedDocument<T>(result);\n }\n\n /**\n * Search resources with type safety\n */\n async searchResourcesTyped<T>(\n model: string,\n filter: Record<string, any> = {},\n aggregate: boolean = false\n ): Promise<TypedSearchResult<T>> {\n const result = await this.client.searchResources(model, filter, aggregate);\n return {\n results: result.results.map((doc) => TypedOperations.toTypedDocument<T>(doc)),\n count: result.count,\n };\n }\n\n /**\n * Get related documents with type safety\n */\n async getRelationDocumentsTyped<T>(\n id: string,\n connection: Record<string, any>\n ): Promise<TypedSearchResult<T>> {\n const result = await this.client.getRelationDocuments(id, connection);\n return {\n results: result.results.map((doc) => TypedOperations.toTypedDocument<T>(doc)),\n count: result.count,\n };\n }\n\n /**\n * Create a new resource with type safety\n */\n async createNewResourceTyped<T>(\n request: CreateAndUpdateRequest\n ): Promise<TypedDocumentStructure<T>> {\n const result = await this.client.createNewResource(request);\n return TypedOperations.toTypedDocument<T>(result);\n }\n\n /**\n * Update a resource with type safety\n */\n async updateResourceTyped<T>(\n request: CreateAndUpdateRequest\n ): Promise<TypedDocumentStructure<T>> {\n const result = await this.client.updateResource(request);\n return TypedOperations.toTypedDocument<T>(result);\n }\n}\n","/**\n * Apito JavaScript internal SDK version (kept in sync with package.json for releases)\n */\nexport const Version = '2.0.0';\n\n/**\n * GetVersion returns the current version of the SDK\n */\nexport function getVersion(): string {\n return Version;\n}\n"],"mappings":";AAAA,OAAOA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,EAAS,MAAM,KAAK,OAAO,qBAAqBF,EAAIM,CAAU,EACpE,MAAO,CACL,QAASJ,EAAO,QAAQ,IAAKG,GAAQV,EAAgB,gBAAmBU,CAAG,CAAC,EAC5E,MAAOH,EAAO,KAChB,CACF,CAKA,MAAM,uBACJK,EACoC,CACpC,IAAML,EAAS,MAAM,KAAK,OAAO,kBAAkBK,CAAO,EAC1D,OAAOZ,EAAgB,gBAAmBO,CAAM,CAClD,CAKA,MAAM,oBACJK,EACoC,CACpC,IAAML,EAAS,MAAM,KAAK,OAAO,eAAeK,CAAO,EACvD,OAAOZ,EAAgB,gBAAmBO,CAAM,CAClD,CACF,ECzFO,IAAMM,EAAU,QAKhB,SAASC,GAAqB,CACjC,OAAOD,CACX","names":["axios","ApitoError","message","code","statusCode","details","GraphQLError","graphQLErrors","response","ValidationError","field","ApitoClient","config","axios","query","variables","options","payload","headers","response","GraphQLError","error","ApitoError","token","tenantId","data","ValidationError","model","id","singlePageData","filter","aggregate","connection","request","stage","createClient","TypedOperations","_TypedOperations","client","raw","data","model","id","singlePageData","result","filter","aggregate","doc","connection","request","Version","getVersion"]}
|