@slates/profiles 1.0.0-rc.6 → 1.0.0-rc.9
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.cjs +6 -3
- package/dist/index.module.js +6 -3
- package/package.json +6 -6
- package/src/client.ts +4 -3
- package/src/store.test.ts +9 -3
- package/src/store.ts +12 -7
- package/src/types.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -183,7 +183,8 @@ var SlatesCliStore = class _SlatesCliStore {
|
|
|
183
183
|
oauthCredentials: parsed.oauthCredentials ?? {}
|
|
184
184
|
} : opts.storePath ? createEmptyStore() : scopeKey ? await loadMigratedLegacyStore(rootDir, scopeKey) : createEmptyStore();
|
|
185
185
|
if (!parsed) {
|
|
186
|
-
await (0, import_promises.writeFile)(storePath, JSON.stringify(data, null, 2)
|
|
186
|
+
await (0, import_promises.writeFile)(storePath, `${JSON.stringify(data, null, 2)}
|
|
187
|
+
`, "utf-8");
|
|
187
188
|
}
|
|
188
189
|
return new _SlatesCliStore(
|
|
189
190
|
rootDir,
|
|
@@ -198,7 +199,8 @@ var SlatesCliStore = class _SlatesCliStore {
|
|
|
198
199
|
await ensureDir(this.dirPath);
|
|
199
200
|
await ensureDir(this.cliDir);
|
|
200
201
|
await ensureGitIgnore(this.cliDir);
|
|
201
|
-
await (0, import_promises.writeFile)(this.storePath, JSON.stringify(this.data, null, 2)
|
|
202
|
+
await (0, import_promises.writeFile)(this.storePath, `${JSON.stringify(this.data, null, 2)}
|
|
203
|
+
`, "utf-8");
|
|
202
204
|
}
|
|
203
205
|
listProfiles() {
|
|
204
206
|
return Object.values(this.data.profiles).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -393,7 +395,8 @@ var shouldRefreshAuth = (auth) => {
|
|
|
393
395
|
if (!hasExpiredOrExpiringOutput(auth)) return false;
|
|
394
396
|
if (auth.authType === "auth.oauth") {
|
|
395
397
|
if (!auth.clientId || !auth.clientSecret) return false;
|
|
396
|
-
if (typeof auth.output?.refreshToken !== "string" || !auth.output.refreshToken)
|
|
398
|
+
if (typeof auth.output?.refreshToken !== "string" || !auth.output.refreshToken)
|
|
399
|
+
return false;
|
|
397
400
|
}
|
|
398
401
|
return true;
|
|
399
402
|
};
|
package/dist/index.module.js
CHANGED
|
@@ -142,7 +142,8 @@ var SlatesCliStore = class _SlatesCliStore {
|
|
|
142
142
|
oauthCredentials: parsed.oauthCredentials ?? {}
|
|
143
143
|
} : opts.storePath ? createEmptyStore() : scopeKey ? await loadMigratedLegacyStore(rootDir, scopeKey) : createEmptyStore();
|
|
144
144
|
if (!parsed) {
|
|
145
|
-
await writeFile(storePath, JSON.stringify(data, null, 2)
|
|
145
|
+
await writeFile(storePath, `${JSON.stringify(data, null, 2)}
|
|
146
|
+
`, "utf-8");
|
|
146
147
|
}
|
|
147
148
|
return new _SlatesCliStore(
|
|
148
149
|
rootDir,
|
|
@@ -157,7 +158,8 @@ var SlatesCliStore = class _SlatesCliStore {
|
|
|
157
158
|
await ensureDir(this.dirPath);
|
|
158
159
|
await ensureDir(this.cliDir);
|
|
159
160
|
await ensureGitIgnore(this.cliDir);
|
|
160
|
-
await writeFile(this.storePath, JSON.stringify(this.data, null, 2)
|
|
161
|
+
await writeFile(this.storePath, `${JSON.stringify(this.data, null, 2)}
|
|
162
|
+
`, "utf-8");
|
|
161
163
|
}
|
|
162
164
|
listProfiles() {
|
|
163
165
|
return Object.values(this.data.profiles).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -352,7 +354,8 @@ var shouldRefreshAuth = (auth) => {
|
|
|
352
354
|
if (!hasExpiredOrExpiringOutput(auth)) return false;
|
|
353
355
|
if (auth.authType === "auth.oauth") {
|
|
354
356
|
if (!auth.clientId || !auth.clientSecret) return false;
|
|
355
|
-
if (typeof auth.output?.refreshToken !== "string" || !auth.output.refreshToken)
|
|
357
|
+
if (typeof auth.output?.refreshToken !== "string" || !auth.output.refreshToken)
|
|
358
|
+
return false;
|
|
356
359
|
}
|
|
357
360
|
return true;
|
|
358
361
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slates/profiles",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"unpkg": "./dist/index.module.js",
|
|
27
27
|
"scripts": {
|
|
28
28
|
"test": "vitest run --passWithNoTests",
|
|
29
|
-
"lint": "prettier src/**/*.ts --check",
|
|
30
29
|
"build": "tsup --config ../../tsup.packages.config.ts --external async_hooks",
|
|
31
|
-
"typecheck": "tsc --noEmit"
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"biome:check": "biome check --write src"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@slates/client": "1.0.0-rc.
|
|
35
|
-
"@slates/proto": "1.0.0-rc.
|
|
34
|
+
"@slates/client": "1.0.0-rc.11",
|
|
35
|
+
"@slates/proto": "1.0.0-rc.10"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@slates/provider": "1.0.0-rc.
|
|
38
|
+
"@slates/provider": "1.0.0-rc.14",
|
|
39
39
|
"@slates/tsconfig": "1.0.0-rc.1",
|
|
40
40
|
"typescript": "5.8.2",
|
|
41
41
|
"vitest": "^3.1.2",
|
package/src/client.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLocalSlateTransport, createSlatesClient } from '@slates/client';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
-
import { resolveSlatesCliRoot, SlatesCliStore } from './store';
|
|
5
|
-
import { SlatesProfileRecord, SlatesStoredAuth } from './types';
|
|
4
|
+
import { resolveSlatesCliRoot, type SlatesCliStore } from './store';
|
|
5
|
+
import type { SlatesProfileRecord, SlatesStoredAuth } from './types';
|
|
6
6
|
|
|
7
7
|
let resolveEntryPath = (entry: string, opts: { cwd?: string; rootDir?: string } = {}) => {
|
|
8
8
|
if (path.isAbsolute(entry)) return entry;
|
|
@@ -82,7 +82,8 @@ let shouldRefreshAuth = (auth: SlatesStoredAuth) => {
|
|
|
82
82
|
|
|
83
83
|
if (auth.authType === 'auth.oauth') {
|
|
84
84
|
if (!auth.clientId || !auth.clientSecret) return false;
|
|
85
|
-
if (typeof auth.output?.refreshToken !== 'string' || !auth.output.refreshToken)
|
|
85
|
+
if (typeof auth.output?.refreshToken !== 'string' || !auth.output.refreshToken)
|
|
86
|
+
return false;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
return true;
|
package/src/store.test.ts
CHANGED
|
@@ -56,7 +56,9 @@ describe('@slates/profiles store', () => {
|
|
|
56
56
|
expect(reopened.getAuth(profile.id, 'token_auth')?.output).toEqual({ token: 'abc' });
|
|
57
57
|
expect(reopened.scope?.key).toBe('integrations/demo');
|
|
58
58
|
expect(reopened.cliDir).toBe(path.join(cwd, '.slates-cli'));
|
|
59
|
-
expect(reopened.storePath).toBe(
|
|
59
|
+
expect(reopened.storePath).toBe(
|
|
60
|
+
path.join(cwd, '.slates-cli', 'profiles', 'integrations', 'demo', 'store.json')
|
|
61
|
+
);
|
|
60
62
|
});
|
|
61
63
|
|
|
62
64
|
it('opens an external scoped store with a separate logical root', async () => {
|
|
@@ -97,7 +99,9 @@ describe('@slates/profiles store', () => {
|
|
|
97
99
|
expect(reopened.scope?.key).toBe('integrations/demo');
|
|
98
100
|
expect(reopened.getProfile()?.target.entry).toBe('integrations/demo/src/index.ts');
|
|
99
101
|
|
|
100
|
-
await expect(
|
|
102
|
+
await expect(
|
|
103
|
+
access(path.join(storageRoot, '.slates-cli', '.gitignore'))
|
|
104
|
+
).resolves.toBeUndefined();
|
|
101
105
|
await expect(access(path.join(workspaceRoot, '.slates-cli'))).rejects.toMatchObject({
|
|
102
106
|
code: 'ENOENT'
|
|
103
107
|
});
|
|
@@ -303,7 +307,9 @@ export let provider = Slate.create({
|
|
|
303
307
|
|
|
304
308
|
let reopened = await SlatesCliStore.open({ storePath: store.storePath });
|
|
305
309
|
expect(reopened.getOAuthCredential(credential.id)?.clientId).toBe('client-id');
|
|
306
|
-
expect(reopened.getOAuthCredential('Primary OAuth App')?.clientSecret).toBe(
|
|
310
|
+
expect(reopened.getOAuthCredential('Primary OAuth App')?.clientSecret).toBe(
|
|
311
|
+
'client-secret'
|
|
312
|
+
);
|
|
307
313
|
});
|
|
308
314
|
|
|
309
315
|
it('refreshes expired OAuth auth automatically in the profile-backed client', async () => {
|
package/src/store.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { execFileSync } from 'child_process';
|
|
|
2
2
|
import { randomUUID } from 'crypto';
|
|
3
3
|
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
6
|
SlatesCliStoreData,
|
|
7
7
|
SlatesCliStoreScope,
|
|
8
8
|
SlatesOAuthCredentialRecord,
|
|
@@ -179,7 +179,12 @@ export class SlatesCliStore {
|
|
|
179
179
|
) {}
|
|
180
180
|
|
|
181
181
|
static async open(
|
|
182
|
-
opts: {
|
|
182
|
+
opts: {
|
|
183
|
+
cwd?: string;
|
|
184
|
+
rootDir?: string;
|
|
185
|
+
scope?: SlatesCliStoreScope;
|
|
186
|
+
storePath?: string;
|
|
187
|
+
} = {}
|
|
183
188
|
) {
|
|
184
189
|
let storageRootDir = opts.storePath
|
|
185
190
|
? inferRootDirFromStorePath(opts.storePath)
|
|
@@ -216,12 +221,12 @@ export class SlatesCliStore {
|
|
|
216
221
|
}
|
|
217
222
|
: opts.storePath
|
|
218
223
|
? createEmptyStore()
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
: scopeKey
|
|
225
|
+
? await loadMigratedLegacyStore(rootDir, scopeKey)
|
|
226
|
+
: createEmptyStore();
|
|
222
227
|
|
|
223
228
|
if (!parsed) {
|
|
224
|
-
await writeFile(storePath, JSON.stringify(data, null, 2)
|
|
229
|
+
await writeFile(storePath, `${JSON.stringify(data, null, 2)}\n`, 'utf-8');
|
|
225
230
|
}
|
|
226
231
|
|
|
227
232
|
return new SlatesCliStore(
|
|
@@ -238,7 +243,7 @@ export class SlatesCliStore {
|
|
|
238
243
|
await ensureDir(this.dirPath);
|
|
239
244
|
await ensureDir(this.cliDir);
|
|
240
245
|
await ensureGitIgnore(this.cliDir);
|
|
241
|
-
await writeFile(this.storePath, JSON.stringify(this.data, null, 2)
|
|
246
|
+
await writeFile(this.storePath, `${JSON.stringify(this.data, null, 2)}\n`, 'utf-8');
|
|
242
247
|
}
|
|
243
248
|
|
|
244
249
|
listProfiles() {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SlatesJsonObject } from '@slates/client';
|
|
2
|
-
import { SlateAuthenticationMethod, SlatesAction } from '@slates/proto';
|
|
1
|
+
import type { SlatesJsonObject } from '@slates/client';
|
|
2
|
+
import type { SlateAuthenticationMethod, SlatesAction } from '@slates/proto';
|
|
3
3
|
|
|
4
4
|
export interface SlatesStoredAuth {
|
|
5
5
|
id: string;
|