@instroc/client 1.0.0-alpha.1 → 1.0.0-alpha.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/dist/index.d.ts +37 -27
- package/dist/index.js +23 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as zustand_vanilla from
|
|
1
|
+
import * as zustand_vanilla from "zustand/vanilla";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Shared config consumed by every @instroc/* SDK package. Lives in a single
|
|
@@ -6,30 +6,30 @@ import * as zustand_vanilla from 'zustand/vanilla';
|
|
|
6
6
|
* functions, and storage in one shot — no provider tree required.
|
|
7
7
|
*/
|
|
8
8
|
interface InstrocConfig {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
/**
|
|
10
|
+
* BaaS project id — required for any SDK call that hits the backend.
|
|
11
|
+
* Null means the SDK is uninitialized; hooks return safe defaults
|
|
12
|
+
* (logged-out / loading=false / no project) until set.
|
|
13
|
+
*/
|
|
14
|
+
projectId: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Base URL the SDK appends `${projectId}/...` paths to.
|
|
17
|
+
* Defaults to `/api/baas` so apps served behind the published-app router
|
|
18
|
+
* just work.
|
|
19
|
+
*/
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* If true, auth persists the session in localStorage and rehydrates on
|
|
23
|
+
* boot. Generated apps almost always want this; set false in tests or
|
|
24
|
+
* embed contexts where you don't want the session to leak across runs.
|
|
25
|
+
*/
|
|
26
|
+
persistSession: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Optional API key for server-to-server data calls. Null in browser apps
|
|
29
|
+
* (auth is per-user via cookies/tokens). Reserved for SSR / Worker
|
|
30
|
+
* scenarios that may show up post-launch.
|
|
31
|
+
*/
|
|
32
|
+
apiKey: string | null;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Caller-supplied init shape. projectId is required; everything else has a
|
|
@@ -37,7 +37,7 @@ interface InstrocConfig {
|
|
|
37
37
|
* forward-compatible — adding a new optional field never breaks callers.
|
|
38
38
|
*/
|
|
39
39
|
interface InitInstrocOptions extends Partial<InstrocConfig> {
|
|
40
|
-
|
|
40
|
+
projectId: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -96,4 +96,14 @@ declare function useInstrocConfig(): InstrocConfig;
|
|
|
96
96
|
*/
|
|
97
97
|
declare function useInstrocReady(): boolean;
|
|
98
98
|
|
|
99
|
-
export {
|
|
99
|
+
export {
|
|
100
|
+
type InitInstrocOptions,
|
|
101
|
+
type InstrocConfig,
|
|
102
|
+
configStore,
|
|
103
|
+
getInstrocConfig,
|
|
104
|
+
initInstroc,
|
|
105
|
+
resetInstroc,
|
|
106
|
+
setInstrocProjectId,
|
|
107
|
+
useInstrocConfig,
|
|
108
|
+
useInstrocReady,
|
|
109
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,29 @@ function initInstroc(options) {
|
|
|
19
19
|
function resetInstroc() {
|
|
20
20
|
configStore.setState({ ...DEFAULT_CONFIG }, true);
|
|
21
21
|
}
|
|
22
|
+
function readEnvVar(name) {
|
|
23
|
+
try {
|
|
24
|
+
const value = globalThis.process?.env?.[name];
|
|
25
|
+
if (typeof value === "string" && value.length > 0) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
(function autoInitFromEnv() {
|
|
33
|
+
const projectId = readEnvVar("INSTROC_PROJECT_ID");
|
|
34
|
+
if (!projectId)
|
|
35
|
+
return;
|
|
36
|
+
const baseUrl = readEnvVar("INSTROC_API_URL");
|
|
37
|
+
const apiKey = readEnvVar("INSTROC_ANON_KEY");
|
|
38
|
+
configStore.setState((prev) => ({
|
|
39
|
+
...prev,
|
|
40
|
+
projectId,
|
|
41
|
+
...baseUrl ? { baseUrl } : {},
|
|
42
|
+
...apiKey ? { apiKey } : {}
|
|
43
|
+
}));
|
|
44
|
+
})();
|
|
22
45
|
function getInstrocConfig() {
|
|
23
46
|
return configStore.getState();
|
|
24
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instroc/client",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "Shared config store for Instroc Cloud SDK packages — initInstroc(), useInstrocConfig(), and the singleton store consumed by @instroc/auth, @instroc/data, @instroc/functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsup",
|
|
19
|
-
"dev": "tsup --watch"
|
|
20
|
-
},
|
|
21
17
|
"peerDependencies": {
|
|
22
18
|
"react": "^18.0.0 || ^19.0.0"
|
|
23
19
|
},
|
|
@@ -36,5 +32,9 @@
|
|
|
36
32
|
},
|
|
37
33
|
"publishConfig": {
|
|
38
34
|
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"dev": "tsup --watch"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|