@qmuse/cloud-client 0.0.1-dev.1 → 0.0.1-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,56 +6,60 @@ its control plane while large file bytes use a platform-specific Storage data
6
6
  plane inside this package.
7
7
 
8
8
  The package intentionally does not expose AppBase clients, Functions, Storage,
9
- TablesDB, endpoint, project ID, database ID, bucket ID, or permissions to
10
- business modules. A QMuse host adapter supplies narrow execution, Session and
11
- file transport capabilities.
9
+ TablesDB, endpoint, project ID, database ID, bucket ID, permissions, or a
10
+ platform-injection API to business modules. Platform implementations are fixed
11
+ by the `/web` and `/miniapp` package entry points.
12
+
13
+ The host initializes one client for the current JavaScript runtime before
14
+ mounting the application. Web and mini-program hosts may load the public
15
+ connection config differently while business modules always read the same
16
+ singleton:
12
17
 
13
18
  ```ts
14
- import { createQmuseCloudClient } from '@qmuse/cloud-client';
19
+ import { getQMuseClient } from '@qmuse/cloud-client';
20
+ import { initQMuseCloudClient } from '@qmuse/cloud-client/web';
15
21
 
16
- export const cloudClient = createQmuseCloudClient({
17
- execute: input => runtime.executeCloudFunction(input),
22
+ await initQMuseCloudClient({
23
+ config: () => hostRuntime.appwrite,
18
24
  });
19
25
 
20
- const result = await cloudClient.request<{ data: Order }>({
26
+ const result = await getQMuseClient().request<{ data: Order }>({
21
27
  method: 'GET',
22
28
  path: '/api/orders/order_1',
23
29
  });
24
30
  ```
25
31
 
26
- Each generated application owns its own users, credentials, sessions, roles,
27
- and policies. It does not reuse the QMuse platform login. AppBase Auth is only
28
- an internal shadow transport identity used for Function runtime headers and
29
- Storage permissions.
32
+ `initQMuseCloudClient` accepts a config object or a sync/async config loader. Calls
33
+ with the same normalized `endpoint`, `projectId`, and `functionId` are
34
+ idempotent and concurrent calls share the same initialization. Reinitializing
35
+ with different connection config is rejected.
36
+
37
+ Each generated application owns its own AppBase users, Sessions, roles and
38
+ policies. The AppBase Session is the only application login state. It supplies
39
+ Function runtime identity headers and Storage permissions; there is no second
40
+ application access/refresh-token layer.
30
41
 
31
- The host supplies an application credential store and the two narrow AppBase
32
- Account operations needed to establish/remove that shadow Session:
42
+ The selected package entry point supplies the AppBase Account capability. Login receives a
43
+ short-lived custom-token secret from the Function and exchanges it immediately;
44
+ the secret is never returned from `login`, persisted, logged or put in business
45
+ state.
33
46
 
34
47
  ```ts
35
- export const cloudClient = createQmuseCloudClient({
36
- execute: input => runtime.executeCloudFunction(input),
37
- auth: {
38
- credentialStore: secureCredentialStore,
39
- shadowSession: {
40
- createSession: input => account.createSession(input),
41
- deleteCurrentSession: () => account.deleteSession({ sessionId: 'current' }),
42
- },
43
- },
44
- });
48
+ import { getQMuseClient } from '@qmuse/cloud-client';
45
49
 
46
- await cloudClient.auth.login({ email, password });
50
+ const cloudClient = getQMuseClient();
51
+ await cloudClient.auth.login({ username, password });
47
52
  const currentUser = await cloudClient.auth.getCurrentUser();
48
53
  await cloudClient.auth.logout();
49
- // Or revoke every application session and every shadow AppBase Session:
54
+ // Or revoke every AppBase Session for this user:
50
55
  await cloudClient.auth.logoutAll();
51
56
  ```
52
57
 
53
- `login/register/refresh` receive a one-time shadow Custom Token from Hono and
54
- exchange it internally. The token secret is never persisted in the application
55
- credential store. Refresh is single-flight, rotates application credentials,
56
- and replaces the current shadow Session. Hosts must back `credentialStore` with
57
- their platform's secure storage policy; this package does not default refresh
58
- tokens to `localStorage`.
58
+ `register` creates the user without changing the current Session. `login`
59
+ exchanges the custom token internally. Session refresh is single-flight and is
60
+ performed before business requests when expiry is within five minutes. Web
61
+ hosts use AppBase's secure cookie; mini-program hosts persist AppBase fallback
62
+ Session headers in storage scoped by endpoint and project ID.
59
63
 
60
64
  Business file operations use a logical resource, never a bucket ID:
61
65
 
@@ -82,42 +86,47 @@ the backend must also expire abandoned intents. Preview/download access is
82
86
  authorized by the Function and may return a short-lived File Token URL or an
83
87
  authenticated URL that the Web transport converts to a disposable Blob URL.
84
88
 
85
- Platform transports are separate package entry points:
89
+ Initialization is available only from platform-specific entry points:
86
90
 
87
91
  ```ts
88
- import { createWebFileTransport } from '@qmuse/cloud-client/web';
89
- import { createMiniappFileTransport } from '@qmuse/cloud-client/miniapp';
92
+ // Web build
93
+ import { initQMuseCloudClient } from '@qmuse/cloud-client/web';
94
+
95
+ await initQMuseCloudClient({
96
+ config: () => window.__MUSE__.appwrite,
97
+ });
98
+
99
+ // Taro mini-program build
100
+ import { initQMuseCloudClient } from '@qmuse/cloud-client/miniapp';
101
+
102
+ await initQMuseCloudClient({
103
+ config: () => getMuseRuntime().appwrite,
104
+ });
90
105
  ```
91
106
 
92
- They migrate the proven file mechanics from the legacy `@qmuse/appwrite`
93
- implementation: Web `File`/`Blob`, Taro-style local paths, 5 MiB chunks,
107
+ The Web entry owns the Appwrite Web SDK and secure-cookie Session. The miniapp
108
+ entry owns Taro request, upload, storage, file-system and project-isolated
109
+ `X-Fallback-Cookies` Session handling. Both entries include the proven file
110
+ mechanics from the legacy `@qmuse/appwrite` implementation: Web `File`/`Blob`, Taro-style local paths, 5 MiB chunks,
94
111
  `Content-Range`, `X-Appwrite-ID` continuation, progress, fallback Session
95
112
  headers and mini-program temporary-file cleanup. They do not migrate TablesDB
96
113
  CRUD or the legacy anonymous `Role.any()` update/delete permissions.
97
114
 
98
- For Web hosts, bind an initialized `Functions` instance without exposing it to
99
- business modules:
115
+ For Web hosts, initialization therefore stays small:
100
116
 
101
117
  ```ts
102
- import { createAppBaseWebCloudClient } from '@qmuse/cloud-client';
118
+ import { initQMuseCloudClient } from '@qmuse/cloud-client/web';
103
119
 
104
- export const cloudClient = createAppBaseWebCloudClient(functions, {
105
- refreshSession,
120
+ export const cloudClient = await initQMuseCloudClient({
121
+ config: () => window.__MUSE__.appwrite,
106
122
  });
107
123
  ```
108
124
 
109
- The legacy portable adapter remains available during migration:
110
-
111
- ```ts
112
- import { createPortableCloudClient } from '@qmuse/cloud-client';
113
-
114
- export const cloudClient = createPortableCloudClient(appwrite);
115
- ```
125
+ `functionId` is the public physical Function ID assigned by the AppBase project.
126
+ It is fixed during initialization and is not supplied by business requests.
116
127
 
117
- New applications should bind Function, Session and file capabilities directly
118
- at their host bootstrap and should not depend on `@qmuse/appwrite` or
119
- `@qmuse/appwrite-runtime-sdk`. The portable adapter only translates this
120
- package's `path` field to the legacy `xpath` field for staged migration.
128
+ New applications should select one platform entry at build time and should not
129
+ depend on `@qmuse/appwrite` or `@qmuse/appwrite-runtime-sdk`.
121
130
 
122
131
  Only `/api` paths and an allowlist of business headers are accepted. The client
123
132
  uses synchronous Function execution, reads `responseStatusCode`, `responseBody`,
@@ -1,15 +1,50 @@
1
- import type { CloudAuthOptions, CloudExecution, CloudExecutionInput, CloudFileTransport, QmuseCloudClient } from './types.js';
1
+ import type { CloudAccountCapability, CloudAuthOptions, CloudExecution, CloudExecutionInput, CloudFileTransport, QmuseCloudClient } from './types.js';
2
+ export type AppBaseExecutionInput = Omit<CloudExecutionInput, 'functionId'> & {
3
+ functionId: string;
4
+ };
2
5
  export interface AppBaseFunctionsCapability {
3
- createExecution(input: CloudExecutionInput): Promise<CloudExecution>;
6
+ createExecution(input: AppBaseExecutionInput): Promise<CloudExecution>;
4
7
  }
5
- export interface PortableExecutionInput extends Omit<CloudExecutionInput, 'path'> {
8
+ export interface AppBaseFunctionsSdkCapability {
9
+ createExecution(...args: never[]): Promise<CloudExecution>;
10
+ }
11
+ export declare function createAppBaseFunctionsCapability(functions: AppBaseFunctionsSdkCapability): AppBaseFunctionsCapability;
12
+ export interface AppBaseAccountSdkCapability {
13
+ createSession(input: {
14
+ userId: string;
15
+ secret: string;
16
+ }): Promise<{
17
+ expire: string;
18
+ }>;
19
+ get(): Promise<{
20
+ $id: string;
21
+ email?: string;
22
+ labels?: string[];
23
+ }>;
24
+ getSession(input: {
25
+ sessionId: 'current';
26
+ }): Promise<{
27
+ expire: string;
28
+ }>;
29
+ updateSession(input: {
30
+ sessionId: 'current';
31
+ }): Promise<{
32
+ expire: string;
33
+ }>;
34
+ deleteSession(input: {
35
+ sessionId: 'current';
36
+ }): Promise<unknown>;
37
+ deleteSessions(): Promise<unknown>;
38
+ }
39
+ export declare function createAppBaseAccountCapability(account: AppBaseAccountSdkCapability): CloudAccountCapability;
40
+ export interface PortableExecutionInput extends Omit<AppBaseExecutionInput, 'path'> {
6
41
  xpath: string;
7
42
  }
8
43
  export interface PortableAppwriteCapability {
9
44
  executeFunction(input: PortableExecutionInput): Promise<CloudExecution>;
10
45
  }
11
46
  export interface HostAdapterOptions<FileSource = never> {
12
- refreshSession?(): Promise<void>;
47
+ functionId?: string;
13
48
  auth?: CloudAuthOptions;
14
49
  fileTransport?: CloudFileTransport<FileSource>;
15
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAYpB,MAAM,WAAW,0BAA0B;IACzC,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC;IAC/E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACzE;AAED,MAAM,WAAW,kBAAkB,CAAC,UAAU,GAAG,KAAK;IACpD,cAAc,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,aAAa,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;CAChD;AAsBD,wBAAgB,2BAA2B,CAAC,UAAU,GAAG,KAAK,EAC5D,SAAS,EAAE,0BAA0B,EACr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seCloudClient } from './client.js';
2
- function isTransportUnauthorized(error) {
3
- if (!error || typeof error !== 'object')
4
- return false;
5
- const value = error;
6
- return [value.code, value.status, value.statusCode, value.response?.status, value.response?.statusCode]
7
- .some(code => Number(code) === 401);
8
- }
9
- async function withTransportRetry(operation, refreshSession) {
10
- try {
11
- return await operation();
2
+ import { toCloudAuthUser } from './auth.js';
3
+ export function createAppBaseFunctionsCapability(functions) {
4
+ if (!functions || typeof functions.createExecution !== 'function') {
5
+ throw new TypeError('An AppBase Functions SDK capability is required');
12
6
  }
13
- catch (error) {
14
- if (!refreshSession || !isTransportUnauthorized(error))
15
- throw error;
16
- await refreshSession();
17
- return operation();
7
+ return {
8
+ createExecution(input) {
9
+ const { path, ...sdkInput } = input;
10
+ return functions.createExecution({ ...sdkInput, xpath: path });
11
+ },
12
+ };
13
+ }
14
+ export function createAppBaseAccountCapability(account) {
15
+ if (!account || typeof account.createSession !== 'function' || typeof account.get !== 'function') {
16
+ throw new TypeError('An AppBase Account SDK capability is required');
18
17
  }
18
+ return {
19
+ createSession: input => account.createSession(input),
20
+ getCurrentUser: async () => toCloudAuthUser(await account.get()),
21
+ getCurrentSession: () => account.getSession({ sessionId: 'current' }),
22
+ refreshCurrentSession: () => account.updateSession({ sessionId: 'current' }),
23
+ deleteCurrentSession: async () => { await account.deleteSession({ sessionId: 'current' }); },
24
+ deleteAllSessions: async () => { await account.deleteSessions(); },
25
+ };
26
+ }
27
+ function executionInput(input, functionId) {
28
+ return {
29
+ ...input,
30
+ functionId: functionId?.trim() || input.functionId,
31
+ };
19
32
  }
20
33
  export function createAppBaseWebCloudClient(functions, options = {}) {
21
34
  if (!functions || typeof functions.createExecution !== 'function') {
22
35
  throw new TypeError('An AppBase Functions capability is required');
23
36
  }
24
37
  return createQmuseCloudClient({
25
- execute: input => withTransportRetry(() => functions.createExecution(input), options.refreshSession),
38
+ execute: input => functions.createExecution(executionInput(input, options.functionId)),
26
39
  ...(options.auth ? { auth: options.auth } : {}),
27
40
  ...(options.fileTransport ? { fileTransport: options.fileTransport } : {}),
28
41
  });
@@ -33,8 +46,8 @@ export function createPortableCloudClient(appwrite, options = {}) {
33
46
  }
34
47
  return createQmuseCloudClient({
35
48
  execute: input => {
36
- const { path, ...portableInput } = input;
37
- return withTransportRetry(() => appwrite.executeFunction({ ...portableInput, xpath: path }), options.refreshSession);
49
+ const { path, ...portableInput } = executionInput(input, options.functionId);
50
+ return appwrite.executeFunction({ ...portableInput, xpath: path });
38
51
  },
39
52
  ...(options.auth ? { auth: options.auth } : {}),
40
53
  ...(options.fileTransport ? { fileTransport: options.fileTransport } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAqCrD,SAAS,uBAAuB,CAAC,KAAc;IAC7C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,KAA2B,CAAC;IAC1C,OAAO,CAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAE;SACtG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,SAA2B,EAC3B,cAAoC;IAEpC,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QACpE,MAAM,cAAc,EAAE,CAAC;QACvB,OAAO,SAAS,EAAE,CAAC;IACr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U,yBAAyB,CACvC,QAAoC,EACpC,UAA0C,EAAE;IAE5C,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,sDAAsD,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,sBAAsB,CAAC;QAC5B,OAAO,EAAE,KAAK,CAAC,EAAE;YACf,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7E,OAAO,QAAQ,CAAC,eAAe,CAAC,EAAE,GAAG,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3E,CAAC,CAAC;AACL,CAAC"}
package/dist/auth.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- import type { CloudAuthOptions, CloudRequest, CloudResponse, QmuseCloudAuth } from './types.js';
2
- type AuthRequest = <T>(request: CloudRequest, accessToken?: string) => Promise<CloudResponse<T>>;
1
+ import type { CloudAuthOptions, CloudAuthUser, CloudRequest, CloudResponse, QmuseCloudAuth } from './types.js';
2
+ type AuthRequest = <T>(request: CloudRequest) => Promise<CloudResponse<T>>;
3
3
  export type CloudAuthRuntime = QmuseCloudAuth & {
4
- accessToken(): Promise<string | undefined>;
4
+ prepareRequest(): Promise<void>;
5
5
  };
6
+ export declare function toCloudAuthUser(value: {
7
+ $id: string;
8
+ email?: string;
9
+ labels?: string[];
10
+ }): CloudAuthUser;
6
11
  export declare function createUnavailableCloudAuth(): CloudAuthRuntime;
7
12
  export declare function createCloudAuth(options: CloudAuthOptions, request: AuthRequest): CloudAuthRuntime;
8
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,gBAAgB,EAKhB,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,KAAK,WAAW,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjG,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAAE,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,CAAC;AAqC/F,wBAAgB,0BAA0B,IAAI,gBAAgB,CAc7D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,gBAAgB,CAuHjG"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAIb,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,KAAK,WAAW,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3E,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAC9C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAoBF,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,aAAa,CAOhB;A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