@anysoftinc/anydb-sdk 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/dist/auth.d.ts +28 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +52 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -0
- package/dist/datascript.query.js +76 -76
- package/dist/nextauth-adapter.d.ts +11 -1
- package/dist/nextauth-adapter.d.ts.map +1 -1
- package/dist/nextauth-adapter.js +25 -4
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -212,6 +212,76 @@ export default NextAuth({
|
|
|
212
212
|
// Your providers
|
|
213
213
|
],
|
|
214
214
|
});
|
|
215
|
+
|
|
216
|
+
Cookie names per app (avoid collisions)
|
|
217
|
+
|
|
218
|
+
If multiple apps share a domain, configure distinct cookie names so sessions don’t collide.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import NextAuth from "next-auth";
|
|
222
|
+
import { AnyDBAdapter, createNextAuthCookies } from "@anysoftinc/anydb-sdk/nextauth-adapter";
|
|
223
|
+
|
|
224
|
+
// ai-pm-suite
|
|
225
|
+
export default NextAuth({
|
|
226
|
+
adapter: AnyDBAdapter(db),
|
|
227
|
+
cookies: createNextAuthCookies("ai-pm-suite", { style: "cookie" }),
|
|
228
|
+
// ... other config
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// dashboard
|
|
232
|
+
export default NextAuth({
|
|
233
|
+
adapter: AnyDBAdapter(db),
|
|
234
|
+
cookies: createNextAuthCookies("dashboard", { style: "cookie" }),
|
|
235
|
+
// ... other config
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
This produces names like `ai-pm-suite.session.cookie`, `ai-pm-suite.callback.cookie`, and `ai-pm-suite.csrf.cookie` (prefixed with `__Host-` in production). Clear existing cookies after changing names.
|
|
240
|
+
|
|
241
|
+
SSO across apps (shared DB)
|
|
242
|
+
|
|
243
|
+
If multiple apps use the same AnyDB auth database and you want single sign-on across them, derive cookie names from the database name so they all share the same cookie namespace:
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
import NextAuth from "next-auth";
|
|
247
|
+
import { AnyDBAdapter, createNextAuthCookiesFromDb } from "@anysoftinc/anydb-sdk/nextauth-adapter";
|
|
248
|
+
|
|
249
|
+
export default NextAuth({
|
|
250
|
+
adapter: AnyDBAdapter(db),
|
|
251
|
+
// Use DB name for cookie namespace to share sessions across apps
|
|
252
|
+
cookies: createNextAuthCookiesFromDb(db, { style: "cookie" }),
|
|
253
|
+
// ... other config
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Auth Helpers (Server-side)
|
|
258
|
+
|
|
259
|
+
Issue AnyDB-compatible HS256 tokens and normalize subjects consistently across apps:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
import { createServiceTokenProvider, signFromSessionClaims } from "@anysoftinc/anydb-sdk/auth";
|
|
263
|
+
|
|
264
|
+
// 1) Service token provider (e.g., for adapters/bootstrap)
|
|
265
|
+
const getServiceToken = createServiceTokenProvider({
|
|
266
|
+
secret: process.env.JWT_SECRET!,
|
|
267
|
+
storageAlias: "dev",
|
|
268
|
+
dbName: "app",
|
|
269
|
+
iss: "my-app-service",
|
|
270
|
+
ttlSeconds: 3600,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Use with DatomicClient
|
|
274
|
+
// new DatomicClient({ baseUrl, getAuthToken: getServiceToken })
|
|
275
|
+
|
|
276
|
+
// 2) Per-user token from NextAuth claims (re-signs JWS for AnyDB)
|
|
277
|
+
const token = signFromSessionClaims({
|
|
278
|
+
claims: nextAuthClaims, // from next-auth/jwt getToken()
|
|
279
|
+
secret: process.env.JWT_SECRET!,
|
|
280
|
+
storageAlias: "dev",
|
|
281
|
+
dbName: "app",
|
|
282
|
+
iss: "my-app-auth",
|
|
283
|
+
ttlSeconds: 900,
|
|
284
|
+
});
|
|
215
285
|
```
|
|
216
286
|
|
|
217
287
|
## Error Handling
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SignAnyDBTokenOptions {
|
|
2
|
+
secret: string;
|
|
3
|
+
sub: string;
|
|
4
|
+
aud: string;
|
|
5
|
+
iss?: string;
|
|
6
|
+
ttlSeconds?: number;
|
|
7
|
+
iat?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function signAnyDBToken(opts: SignAnyDBTokenOptions): string;
|
|
10
|
+
export interface ServiceTokenProviderOptions {
|
|
11
|
+
secret: string;
|
|
12
|
+
storageAlias: string;
|
|
13
|
+
dbName: string;
|
|
14
|
+
iss?: string;
|
|
15
|
+
ttlSeconds?: number;
|
|
16
|
+
sub?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function createServiceTokenProvider(opts: ServiceTokenProviderOptions): () => string;
|
|
19
|
+
export interface SignFromSessionClaimsOptions {
|
|
20
|
+
claims: Record<string, any>;
|
|
21
|
+
secret: string;
|
|
22
|
+
storageAlias: string;
|
|
23
|
+
dbName: string;
|
|
24
|
+
iss?: string;
|
|
25
|
+
ttlSeconds?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function signFromSessionClaims(opts: SignFromSessionClaimsOptions): string;
|
|
28
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAgBlE;AAKD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,2BAA2B,GAChC,MAAM,MAAM,CAQd;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,4BAA4B,GACjC,MAAM,CAUR"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Auth utilities for issuing AnyDB-compatible JWS tokens and normalizing subjects
|
|
2
|
+
// Server-only: depends on Node's crypto for HMAC-SHA256
|
|
3
|
+
import { createHmac } from "crypto";
|
|
4
|
+
function base64url(input) {
|
|
5
|
+
const buf = Buffer.isBuffer(input) ? input : Buffer.from(input);
|
|
6
|
+
return buf
|
|
7
|
+
.toString("base64")
|
|
8
|
+
.replace(/=/g, "")
|
|
9
|
+
.replace(/\+/g, "-")
|
|
10
|
+
.replace(/\//g, "_");
|
|
11
|
+
}
|
|
12
|
+
function hmacSha256(data, secret) {
|
|
13
|
+
return createHmac("sha256", secret).update(data).digest();
|
|
14
|
+
}
|
|
15
|
+
function nowSeconds() {
|
|
16
|
+
return Math.floor(Date.now() / 1000);
|
|
17
|
+
}
|
|
18
|
+
export function signAnyDBToken(opts) {
|
|
19
|
+
const iat = opts.iat ?? nowSeconds();
|
|
20
|
+
const exp = iat + (opts.ttlSeconds ?? 15 * 60);
|
|
21
|
+
const header = { alg: "HS256", typ: "JWT" };
|
|
22
|
+
const payload = {
|
|
23
|
+
sub: opts.sub,
|
|
24
|
+
aud: opts.aud,
|
|
25
|
+
iss: opts.iss || "anydb-sdk",
|
|
26
|
+
iat,
|
|
27
|
+
exp,
|
|
28
|
+
};
|
|
29
|
+
const hB64 = base64url(JSON.stringify(header));
|
|
30
|
+
const pB64 = base64url(JSON.stringify(payload));
|
|
31
|
+
const signingInput = `${hB64}.${pB64}`;
|
|
32
|
+
const sig = base64url(hmacSha256(signingInput, opts.secret));
|
|
33
|
+
return `${signingInput}.${sig}`;
|
|
34
|
+
}
|
|
35
|
+
export function createServiceTokenProvider(opts) {
|
|
36
|
+
const iss = opts.iss || "anydb-sdk-service";
|
|
37
|
+
const ttl = opts.ttlSeconds ?? 60 * 60;
|
|
38
|
+
const aud = `${opts.storageAlias}/${opts.dbName}`;
|
|
39
|
+
const sub = opts.sub || "[:db/ident :anydb.system.v1/subject]";
|
|
40
|
+
return () => signAnyDBToken({ secret: opts.secret, sub, aud, iss, ttlSeconds: ttl });
|
|
41
|
+
}
|
|
42
|
+
export function signFromSessionClaims(opts) {
|
|
43
|
+
const iss = opts.iss || "anydb-sdk-auth";
|
|
44
|
+
const ttl = opts.ttlSeconds ?? 15 * 60;
|
|
45
|
+
const aud = `${opts.storageAlias}/${opts.dbName}`;
|
|
46
|
+
const rawSub = opts.claims?.sub;
|
|
47
|
+
if (typeof rawSub !== "string" || !rawSub.trim()) {
|
|
48
|
+
throw new Error("Invalid session: missing or invalid 'sub' in claims");
|
|
49
|
+
}
|
|
50
|
+
const sub = rawSub;
|
|
51
|
+
return signAnyDBToken({ secret: opts.secret, sub, aud, iss, ttlSeconds: ttl });
|
|
52
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -87,6 +87,8 @@ export declare class AnyDBClient {
|
|
|
87
87
|
private storageAlias;
|
|
88
88
|
private dbName;
|
|
89
89
|
constructor(client: DatomicClient, storageAlias: string, dbName: string);
|
|
90
|
+
getDbName(): string;
|
|
91
|
+
getStorageAlias(): string;
|
|
90
92
|
info(): Promise<DatabaseInfo>;
|
|
91
93
|
transact(txData: any[]): Promise<Transaction>;
|
|
92
94
|
query(q: SymbolicQuery, ...args: any[]): Promise<QueryResult>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,KAAG,MAA4C,CAAC;AAChF,eAAO,MAAM,IAAI,GAAI,IAAI,MAAM,KAAG,IAAsC,CAAC;AACzE,eAAO,MAAM,EAAE,GAAI,MAAM,MAAM,KAAG,OAajC,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,GAAG,EAAE,CAAC;AACV,MAAM,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,G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CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,GAAG,CAAC;QACR,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,GAAG,CAAC,EAAE,GAAG,CAAC;QACV,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACd,GACL,OAAO,CAAC,KAAK,EAAE,CAAC;IAwBnB,iBAAiB,CACf,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,EACtC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAC/B,WAAW;CAQf;AAID,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAEvE;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,WAAW,CAEb;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAGrD;AAGD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;AAEtD,eAAe,aAAa,CAAC;AAoB7B,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,WAAW,EACf,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA4Cf"}
|
package/dist/client.js
CHANGED
|
@@ -272,6 +272,13 @@ export class AnyDBClient {
|
|
|
272
272
|
this.storageAlias = storageAlias;
|
|
273
273
|
this.dbName = dbName;
|
|
274
274
|
}
|
|
275
|
+
// Expose identifiers for consumers that need deterministic naming
|
|
276
|
+
getDbName() {
|
|
277
|
+
return this.dbName;
|
|
278
|
+
}
|
|
279
|
+
getStorageAlias() {
|
|
280
|
+
return this.storageAlias;
|
|
281
|
+
}
|
|
275
282
|
async info() {
|
|
276
283
|
if (shouldUseDataScript(this.storageAlias)) {
|
|
277
284
|
const backend = new DataScriptBackend(this.storageAlias, this.dbName);
|
package/dist/datascript.query.js
CHANGED
|
@@ -64,12 +64,12 @@ var this__5300__auto____$1 = this;
|
|
|
64
64
|
return this__5300__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__5301__auto__,null);
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
-
(datascript.query.Context.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5302__auto__,
|
|
67
|
+
(datascript.query.Context.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5302__auto__,k8902,else__5303__auto__){
|
|
68
68
|
var self__ = this;
|
|
69
69
|
var this__5302__auto____$1 = this;
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
switch (
|
|
70
|
+
var G__8931 = k8902;
|
|
71
|
+
var G__8931__$1 = (((G__8931 instanceof cljs.core.Keyword))?G__8931.fqn:null);
|
|
72
|
+
switch (G__8931__$1) {
|
|
73
73
|
case "rels":
|
|
74
74
|
return self__.rels;
|
|
75
75
|
|
|
@@ -83,7 +83,7 @@ return self__.rules;
|
|
|
83
83
|
|
|
84
84
|
break;
|
|
85
85
|
default:
|
|
86
|
-
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,
|
|
86
|
+
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k8902,else__5303__auto__);
|
|
87
87
|
|
|
88
88
|
}
|
|
89
89
|
}));
|
|
@@ -91,10 +91,10 @@ return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k9251,else__5
|
|
|
91
91
|
(datascript.query.Context.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__5320__auto__,f__5321__auto__,init__5322__auto__){
|
|
92
92
|
var self__ = this;
|
|
93
93
|
var this__5320__auto____$1 = this;
|
|
94
|
-
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5323__auto__,
|
|
95
|
-
var
|
|
96
|
-
var k__5324__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(
|
|
97
|
-
var v__5325__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(
|
|
94
|
+
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5323__auto__,p__8982){
|
|
95
|
+
var vec__9004 = p__8982;
|
|
96
|
+
var k__5324__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__9004,(0),null);
|
|
97
|
+
var v__5325__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__9004,(1),null);
|
|
98
98
|
return (f__5321__auto__.cljs$core$IFn$_invoke$arity$3 ? f__5321__auto__.cljs$core$IFn$_invoke$arity$3(ret__5323__auto__,k__5324__auto__,v__5325__auto__) : f__5321__auto__.call(null,ret__5323__auto__,k__5324__auto__,v__5325__auto__));
|
|
99
99
|
}),init__5322__auto__,this__5320__auto____$1);
|
|
100
100
|
}));
|
|
@@ -108,10 +108,10 @@ return cljs.core.pr_sequential_writer(writer__5316__auto__,cljs.core.pr_writer,"
|
|
|
108
108
|
return cljs.core.pr_sequential_writer(writer__5316__auto__,pr_pair__5318__auto__,"#datascript.query.Context{",", ","}",opts__5317__auto__,cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"rels","rels",1770187185),self__.rels],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"sources","sources",-321166424),self__.sources],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"rules","rules",1198912366),self__.rules],null))], null),self__.__extmap));
|
|
109
109
|
}));
|
|
110
110
|
|
|
111
|
-
(datascript.query.Context.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (
|
|
111
|
+
(datascript.query.Context.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__8901){
|
|
112
112
|
var self__ = this;
|
|
113
|
-
var
|
|
114
|
-
return (new cljs.core.RecordIter((0),
|
|
113
|
+
var G__8901__$1 = this;
|
|
114
|
+
return (new cljs.core.RecordIter((0),G__8901__$1,3,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"rels","rels",1770187185),new cljs.core.Keyword(null,"sources","sources",-321166424),new cljs.core.Keyword(null,"rules","rules",1198912366)], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator(self__.__extmap):cljs.core.nil_iter())));
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
117
|
(datascript.query.Context.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__5298__auto__){
|
|
@@ -148,10 +148,10 @@ return h__5111__auto____$1;
|
|
|
148
148
|
}
|
|
149
149
|
}));
|
|
150
150
|
|
|
151
|
-
(datascript.query.Context.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (
|
|
151
|
+
(datascript.query.Context.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this8903,other8904){
|
|
152
152
|
var self__ = this;
|
|
153
|
-
var
|
|
154
|
-
return (((!((
|
|
153
|
+
var this8903__$1 = this;
|
|
154
|
+
return (((!((other8904 == null)))) && ((((this8903__$1.constructor === other8904.constructor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8903__$1.rels,other8904.rels)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8903__$1.sources,other8904.sources)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8903__$1.rules,other8904.rules)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8903__$1.__extmap,other8904.__extmap)))))))))));
|
|
155
155
|
}));
|
|
156
156
|
|
|
157
157
|
(datascript.query.Context.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__5310__auto__,k__5311__auto__){
|
|
@@ -164,12 +164,12 @@ return (new datascript.query.Context(self__.rels,self__.sources,self__.rules,sel
|
|
|
164
164
|
}
|
|
165
165
|
}));
|
|
166
166
|
|
|
167
|
-
(datascript.query.Context.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5307__auto__,
|
|
167
|
+
(datascript.query.Context.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5307__auto__,k8902){
|
|
168
168
|
var self__ = this;
|
|
169
169
|
var this__5307__auto____$1 = this;
|
|
170
|
-
var
|
|
171
|
-
var
|
|
172
|
-
switch (
|
|
170
|
+
var G__9110 = k8902;
|
|
171
|
+
var G__9110__$1 = (((G__9110 instanceof cljs.core.Keyword))?G__9110.fqn:null);
|
|
172
|
+
switch (G__9110__$1) {
|
|
173
173
|
case "rels":
|
|
174
174
|
case "sources":
|
|
175
175
|
case "rules":
|
|
@@ -177,26 +177,26 @@ return true;
|
|
|
177
177
|
|
|
178
178
|
break;
|
|
179
179
|
default:
|
|
180
|
-
return cljs.core.contains_QMARK_(self__.__extmap,
|
|
180
|
+
return cljs.core.contains_QMARK_(self__.__extmap,k8902);
|
|
181
181
|
|
|
182
182
|
}
|
|
183
183
|
}));
|
|
184
184
|
|
|
185
|
-
(datascript.query.Context.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5308__auto__,k__5309__auto__,
|
|
185
|
+
(datascript.query.Context.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5308__auto__,k__5309__auto__,G__8901){
|
|
186
186
|
var self__ = this;
|
|
187
187
|
var this__5308__auto____$1 = this;
|
|
188
|
-
var
|
|
189
|
-
var
|
|
190
|
-
if(cljs.core.truth_((
|
|
191
|
-
return (new datascript.query.Context(
|
|
188
|
+
var pred__9118 = cljs.core.keyword_identical_QMARK_;
|
|
189
|
+
var expr__9119 = k__5309__auto__;
|
|
190
|
+
if(cljs.core.truth_((pred__9118.cljs$core$IFn$_invoke$arity$2 ? pred__9118.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"rels","rels",1770187185),expr__9119) : pred__9118.call(null,new cljs.core.Keyword(null,"rels","rels",1770187185),expr__9119)))){
|
|
191
|
+
return (new datascript.query.Context(G__8901,self__.sources,self__.rules,self__.__meta,self__.__extmap,null));
|
|
192
192
|
} else {
|
|
193
|
-
if(cljs.core.truth_((
|
|
194
|
-
return (new datascript.query.Context(self__.rels,
|
|
193
|
+
if(cljs.core.truth_((pred__9118.cljs$core$IFn$_invoke$arity$2 ? pred__9118.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"sources","sources",-321166424),expr__9119) : pred__9118.call(null,new cljs.core.Keyword(null,"sources","sources",-321166424),expr__9119)))){
|
|
194
|
+
return (new datascript.query.Context(self__.rels,G__8901,self__.rules,self__.__meta,self__.__extmap,null));
|
|
195
195
|
} else {
|
|
196
|
-
if(cljs.core.truth_((
|
|
197
|
-
return (new datascript.query.Context(self__.rels,self__.sources,
|
|
196
|
+
if(cljs.core.truth_((pred__9118.cljs$core$IFn$_invoke$arity$2 ? pred__9118.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"rules","rules",1198912366),expr__9119) : pred__9118.call(null,new cljs.core.Keyword(null,"rules","rules",1198912366),expr__9119)))){
|
|
197
|
+
return (new datascript.query.Context(self__.rels,self__.sources,G__8901,self__.__meta,self__.__extmap,null));
|
|
198
198
|
} else {
|
|
199
|
-
return (new datascript.query.Context(self__.rels,self__.sources,self__.rules,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5309__auto__,
|
|
199
|
+
return (new datascript.query.Context(self__.rels,self__.sources,self__.rules,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5309__auto__,G__8901),null));
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
|
@@ -208,10 +208,10 @@ var this__5313__auto____$1 = this;
|
|
|
208
208
|
return cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(new cljs.core.Keyword(null,"rels","rels",1770187185),self__.rels,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"sources","sources",-321166424),self__.sources,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"rules","rules",1198912366),self__.rules,null))], null),self__.__extmap));
|
|
209
209
|
}));
|
|
210
210
|
|
|
211
|
-
(datascript.query.Context.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5299__auto__,
|
|
211
|
+
(datascript.query.Context.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5299__auto__,G__8901){
|
|
212
212
|
var self__ = this;
|
|
213
213
|
var this__5299__auto____$1 = this;
|
|
214
|
-
return (new datascript.query.Context(self__.rels,self__.sources,self__.rules,
|
|
214
|
+
return (new datascript.query.Context(self__.rels,self__.sources,self__.rules,G__8901,self__.__extmap,self__.__hash));
|
|
215
215
|
}));
|
|
216
216
|
|
|
217
217
|
(datascript.query.Context.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__5305__auto__,entry__5306__auto__){
|
|
@@ -248,15 +248,15 @@ return (new datascript.query.Context(rels,sources,rules,null,null,null));
|
|
|
248
248
|
/**
|
|
249
249
|
* Factory function for datascript.query/Context, taking a map of keywords to field values.
|
|
250
250
|
*/
|
|
251
|
-
datascript.query.map__GT_Context = (function datascript$query$map__GT_Context(
|
|
252
|
-
var extmap__5342__auto__ = (function (){var
|
|
253
|
-
if(cljs.core.record_QMARK_(
|
|
254
|
-
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,
|
|
251
|
+
datascript.query.map__GT_Context = (function datascript$query$map__GT_Context(G__8905){
|
|
252
|
+
var extmap__5342__auto__ = (function (){var G__9134 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$variadic(G__8905,new cljs.core.Keyword(null,"rels","rels",1770187185),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"sources","sources",-321166424),new cljs.core.Keyword(null,"rules","rules",1198912366)], 0));
|
|
253
|
+
if(cljs.core.record_QMARK_(G__8905)){
|
|
254
|
+
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,G__9134);
|
|
255
255
|
} else {
|
|
256
|
-
return
|
|
256
|
+
return G__9134;
|
|
257
257
|
}
|
|
258
258
|
})();
|
|
259
|
-
return (new datascript.query.Context(new cljs.core.Keyword(null,"rels","rels",1770187185).cljs$core$IFn$_invoke$arity$1(
|
|
259
|
+
return (new datascript.query.Context(new cljs.core.Keyword(null,"rels","rels",1770187185).cljs$core$IFn$_invoke$arity$1(G__8905),new cljs.core.Keyword(null,"sources","sources",-321166424).cljs$core$IFn$_invoke$arity$1(G__8905),new cljs.core.Keyword(null,"rules","rules",1198912366).cljs$core$IFn$_invoke$arity$1(G__8905),null,cljs.core.not_empty(extmap__5342__auto__),null));
|
|
260
260
|
});
|
|
261
261
|
|
|
262
262
|
|
|
@@ -293,12 +293,12 @@ var this__5300__auto____$1 = this;
|
|
|
293
293
|
return this__5300__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__5301__auto__,null);
|
|
294
294
|
}));
|
|
295
295
|
|
|
296
|
-
(datascript.query.Relation.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5302__auto__,
|
|
296
|
+
(datascript.query.Relation.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5302__auto__,k9138,else__5303__auto__){
|
|
297
297
|
var self__ = this;
|
|
298
298
|
var this__5302__auto____$1 = this;
|
|
299
|
-
var
|
|
300
|
-
var
|
|
301
|
-
switch (
|
|
299
|
+
var G__9155 = k9138;
|
|
300
|
+
var G__9155__$1 = (((G__9155 instanceof cljs.core.Keyword))?G__9155.fqn:null);
|
|
301
|
+
switch (G__9155__$1) {
|
|
302
302
|
case "attrs":
|
|
303
303
|
return self__.attrs;
|
|
304
304
|
|
|
@@ -308,7 +308,7 @@ return self__.tuples;
|
|
|
308
308
|
|
|
309
309
|
break;
|
|
310
310
|
default:
|
|
311
|
-
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,
|
|
311
|
+
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k9138,else__5303__auto__);
|
|
312
312
|
|
|
313
313
|
}
|
|
314
314
|
}));
|
|
@@ -316,10 +316,10 @@ return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k9266,else__5
|
|
|
316
316
|
(datascript.query.Relation.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__5320__auto__,f__5321__auto__,init__5322__auto__){
|
|
317
317
|
var self__ = this;
|
|
318
318
|
var this__5320__auto____$1 = this;
|
|
319
|
-
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5323__auto__,
|
|
320
|
-
var
|
|
321
|
-
var k__5324__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(
|
|
322
|
-
var v__5325__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(
|
|
319
|
+
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5323__auto__,p__9165){
|
|
320
|
+
var vec__9167 = p__9165;
|
|
321
|
+
var k__5324__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__9167,(0),null);
|
|
322
|
+
var v__5325__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__9167,(1),null);
|
|
323
323
|
return (f__5321__auto__.cljs$core$IFn$_invoke$arity$3 ? f__5321__auto__.cljs$core$IFn$_invoke$arity$3(ret__5323__auto__,k__5324__auto__,v__5325__auto__) : f__5321__auto__.call(null,ret__5323__auto__,k__5324__auto__,v__5325__auto__));
|
|
324
324
|
}),init__5322__auto__,this__5320__auto____$1);
|
|
325
325
|
}));
|
|
@@ -333,10 +333,10 @@ return cljs.core.pr_sequential_writer(writer__5316__auto__,cljs.core.pr_writer,"
|
|
|
333
333
|
return cljs.core.pr_sequential_writer(writer__5316__auto__,pr_pair__5318__auto__,"#datascript.query.Relation{",", ","}",opts__5317__auto__,cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"attrs","attrs",-2090668713),self__.attrs],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"tuples","tuples",-676032639),self__.tuples],null))], null),self__.__extmap));
|
|
334
334
|
}));
|
|
335
335
|
|
|
336
|
-
(datascript.query.Relation.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (
|
|
336
|
+
(datascript.query.Relation.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__9137){
|
|
337
337
|
var self__ = this;
|
|
338
|
-
var
|
|
339
|
-
return (new cljs.core.RecordIter((0),
|
|
338
|
+
var G__9137__$1 = this;
|
|
339
|
+
return (new cljs.core.RecordIter((0),G__9137__$1,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"attrs","attrs",-2090668713),new cljs.core.Keyword(null,"tuples","tuples",-676032639)], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator(self__.__extmap):cljs.core.nil_iter())));
|
|
340
340
|
}));
|
|
341
341
|
|
|
342
342
|
(datascript.query.Relation.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__5298__auto__){
|
|
@@ -373,10 +373,10 @@ return h__5111__auto____$1;
|
|
|
373
373
|
}
|
|
374
374
|
}));
|
|
375
375
|
|
|
376
|
-
(datascript.query.Relation.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (
|
|
376
|
+
(datascript.query.Relation.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this9139,other9140){
|
|
377
377
|
var self__ = this;
|
|
378
|
-
var
|
|
379
|
-
return (((!((
|
|
378
|
+
var this9139__$1 = this;
|
|
379
|
+
return (((!((other9140 == null)))) && ((((this9139__$1.constructor === other9140.constructor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this9139__$1.attrs,other9140.attrs)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this9139__$1.tuples,other9140.tuples)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this9139__$1.__extmap,other9140.__extmap)))))))));
|
|
380
380
|
}));
|
|
381
381
|
|
|
382
382
|
(datascript.query.Relation.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__5310__auto__,k__5311__auto__){
|
|
@@ -389,35 +389,35 @@ return (new datascript.query.Relation(self__.attrs,self__.tuples,self__.__meta,c
|
|
|
389
389
|
}
|
|
390
390
|
}));
|
|
391
391
|
|
|
392
|
-
(datascript.query.Relation.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5307__auto__,
|
|
392
|
+
(datascript.query.Relation.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5307__auto__,k9138){
|
|
393
393
|
var self__ = this;
|
|
394
394
|
var this__5307__auto____$1 = this;
|
|
395
|
-
var
|
|
396
|
-
var
|
|
397
|
-
switch (
|
|
395
|
+
var G__9210 = k9138;
|
|
396
|
+
var G__9210__$1 = (((G__9210 instanceof cljs.core.Keyword))?G__9210.fqn:null);
|
|
397
|
+
switch (G__9210__$1) {
|
|
398
398
|
case "attrs":
|
|
399
399
|
case "tuples":
|
|
400
400
|
return true;
|
|
401
401
|
|
|
402
402
|
break;
|
|
403
403
|
default:
|
|
404
|
-
return cljs.core.contains_QMARK_(self__.__extmap,
|
|
404
|
+
return cljs.core.contains_QMARK_(self__.__extmap,k9138);
|
|
405
405
|
|
|
406
406
|
}
|
|
407
407
|
}));
|
|
408
408
|
|
|
409
|
-
(datascript.query.Relation.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5308__auto__,k__5309__auto__,
|
|
409
|
+
(datascript.query.Relation.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5308__auto__,k__5309__auto__,G__9137){
|
|
410
410
|
var self__ = this;
|
|
411
411
|
var this__5308__auto____$1 = this;
|
|
412
|
-
var
|
|
413
|
-
var
|
|
414
|
-
if(cljs.core.truth_((
|
|
415
|
-
return (new datascript.query.Relation(
|
|
412
|
+
var pred__9212 = cljs.core.keyword_identical_QMARK_;
|
|
413
|
+
var expr__9213 = k__5309__auto__;
|
|
414
|
+
if(cljs.core.truth_((pred__9212.cljs$core$IFn$_invoke$arity$2 ? pred__9212.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"attrs","attrs",-2090668713),expr__9213) : pred__9212.call(null,new cljs.core.Keyword(null,"attrs","attrs",-2090668713),expr__9213)))){
|
|
415
|
+
return (new datascript.query.Relation(G__9137,self__.tuples,self__.__meta,self__.__extmap,null));
|
|
416
416
|
} else {
|
|
417
|
-
if(cljs.core.truth_((
|
|
418
|
-
return (new datascript.query.Relation(self__.attrs,
|
|
417
|
+
if(cljs.core.truth_((pred__9212.cljs$core$IFn$_invoke$arity$2 ? pred__9212.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"tuples","tuples",-676032639),expr__9213) : pred__9212.call(null,new cljs.core.Keyword(null,"tuples","tuples",-676032639),expr__9213)))){
|
|
418
|
+
return (new datascript.query.Relation(self__.attrs,G__9137,self__.__meta,self__.__extmap,null));
|
|
419
419
|
} else {
|
|
420
|
-
return (new datascript.query.Relation(self__.attrs,self__.tuples,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5309__auto__,
|
|
420
|
+
return (new datascript.query.Relation(self__.attrs,self__.tuples,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5309__auto__,G__9137),null));
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
}));
|
|
@@ -428,10 +428,10 @@ var this__5313__auto____$1 = this;
|
|
|
428
428
|
return cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(new cljs.core.Keyword(null,"attrs","attrs",-2090668713),self__.attrs,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"tuples","tuples",-676032639),self__.tuples,null))], null),self__.__extmap));
|
|
429
429
|
}));
|
|
430
430
|
|
|
431
|
-
(datascript.query.Relation.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5299__auto__,
|
|
431
|
+
(datascript.query.Relation.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5299__auto__,G__9137){
|
|
432
432
|
var self__ = this;
|
|
433
433
|
var this__5299__auto____$1 = this;
|
|
434
|
-
return (new datascript.query.Relation(self__.attrs,self__.tuples,
|
|
434
|
+
return (new datascript.query.Relation(self__.attrs,self__.tuples,G__9137,self__.__extmap,self__.__hash));
|
|
435
435
|
}));
|
|
436
436
|
|
|
437
437
|
(datascript.query.Relation.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__5305__auto__,entry__5306__auto__){
|
|
@@ -468,15 +468,15 @@ return (new datascript.query.Relation(attrs,tuples,null,null,null));
|
|
|
468
468
|
/**
|
|
469
469
|
* Factory function for datascript.query/Relation, taking a map of keywords to field values.
|
|
470
470
|
*/
|
|
471
|
-
datascript.query.map__GT_Relation = (function datascript$query$map__GT_Relation(
|
|
472
|
-
var extmap__5342__auto__ = (function (){var
|
|
473
|
-
if(cljs.core.record_QMARK_(
|
|
474
|
-
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,
|
|
471
|
+
datascript.query.map__GT_Relation = (function datascript$query$map__GT_Relation(G__9147){
|
|
472
|
+
var extmap__5342__auto__ = (function (){var G__9235 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$variadic(G__9147,new cljs.core.Keyword(null,"attrs","attrs",-2090668713),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"tuples","tuples",-676032639)], 0));
|
|
473
|
+
if(cljs.core.record_QMARK_(G__9147)){
|
|
474
|
+
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,G__9235);
|
|
475
475
|
} else {
|
|
476
|
-
return
|
|
476
|
+
return G__9235;
|
|
477
477
|
}
|
|
478
478
|
})();
|
|
479
|
-
return (new datascript.query.Relation(new cljs.core.Keyword(null,"attrs","attrs",-2090668713).cljs$core$IFn$_invoke$arity$1(
|
|
479
|
+
return (new datascript.query.Relation(new cljs.core.Keyword(null,"attrs","attrs",-2090668713).cljs$core$IFn$_invoke$arity$1(G__9147),new cljs.core.Keyword(null,"tuples","tuples",-676032639).cljs$core$IFn$_invoke$arity$1(G__9147),null,cljs.core.not_empty(extmap__5342__auto__),null));
|
|
480
480
|
});
|
|
481
481
|
|
|
482
482
|
datascript.query.single = (function datascript$query$single(coll){
|
|
@@ -517,9 +517,9 @@ return cljs.core.into.cljs$core$IFn$_invoke$arity$3(cljs.core.PersistentVector.E
|
|
|
517
517
|
(datascript.query.concatv.cljs$lang$maxFixedArity = (0));
|
|
518
518
|
|
|
519
519
|
/** @this {Function} */
|
|
520
|
-
(datascript.query.concatv.cljs$lang$applyTo = (function (
|
|
520
|
+
(datascript.query.concatv.cljs$lang$applyTo = (function (seq9256){
|
|
521
521
|
var self__5712__auto__ = this;
|
|
522
|
-
return self__5712__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq(
|
|
522
|
+
return self__5712__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq(seq9256));
|
|
523
523
|
}));
|
|
524
524
|
|
|
525
525
|
datascript.query.zip = (function datascript$query$zip(var_args){
|
|
@@ -4,7 +4,17 @@ import type { AnyDBClient } from "./client";
|
|
|
4
4
|
* Creates NextAuth cookie configuration with proper security settings
|
|
5
5
|
* Uses __Host- prefix and secure cookies in production, regular cookies in development
|
|
6
6
|
*/
|
|
7
|
-
export declare function createNextAuthCookies(cookieIdentifier: string
|
|
7
|
+
export declare function createNextAuthCookies(cookieIdentifier: string, opts?: {
|
|
8
|
+
style?: "token" | "cookie";
|
|
9
|
+
}): Record<string, any>;
|
|
10
|
+
/**
|
|
11
|
+
* Derive cookie names from the connected database, enabling SSO across apps
|
|
12
|
+
* that share the same auth database. If multiple apps point to the same DB name,
|
|
13
|
+
* they will share the same cookie namespace and thus sessions.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createNextAuthCookiesFromDb(db: AnyDBClient, opts?: {
|
|
16
|
+
style?: "token" | "cookie";
|
|
17
|
+
}): Record<string, any>;
|
|
8
18
|
/**
|
|
9
19
|
* Creates a NextAuth.js adapter for AnyDB/Datomic
|
|
10
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextauth-adapter.d.ts","sourceRoot":"","sources":["../src/nextauth-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,UAAU,CAAC;AAI3D;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nextauth-adapter.d.ts","sourceRoot":"","sources":["../src/nextauth-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,UAAU,CAAC;AAI3D;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAAE,GACpC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAgDrB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,WAAW,EACf,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAAE,GACpC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAGrB;AA2DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CA6WrD"}
|
package/dist/nextauth-adapter.js
CHANGED
|
@@ -4,13 +4,25 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
4
4
|
* Creates NextAuth cookie configuration with proper security settings
|
|
5
5
|
* Uses __Host- prefix and secure cookies in production, regular cookies in development
|
|
6
6
|
*/
|
|
7
|
-
export function createNextAuthCookies(cookieIdentifier) {
|
|
7
|
+
export function createNextAuthCookies(cookieIdentifier, opts) {
|
|
8
8
|
const isProduction = process.env.NODE_ENV === "production";
|
|
9
9
|
const prefix = isProduction ? "__Host-" : "";
|
|
10
10
|
const secure = isProduction;
|
|
11
|
+
const style = opts?.style ?? "token";
|
|
12
|
+
const names = style === "cookie"
|
|
13
|
+
? {
|
|
14
|
+
session: `${prefix}${cookieIdentifier}.session.cookie`,
|
|
15
|
+
callback: `${prefix}${cookieIdentifier}.callback.cookie`,
|
|
16
|
+
csrf: `${prefix}${cookieIdentifier}.csrf.cookie`,
|
|
17
|
+
}
|
|
18
|
+
: {
|
|
19
|
+
session: `${prefix}${cookieIdentifier}.session-token`,
|
|
20
|
+
callback: `${prefix}${cookieIdentifier}.callback-url`,
|
|
21
|
+
csrf: `${prefix}${cookieIdentifier}.csrf-token`,
|
|
22
|
+
};
|
|
11
23
|
return {
|
|
12
24
|
sessionToken: {
|
|
13
|
-
name:
|
|
25
|
+
name: names.session,
|
|
14
26
|
options: {
|
|
15
27
|
httpOnly: true,
|
|
16
28
|
sameSite: "lax",
|
|
@@ -19,7 +31,7 @@ export function createNextAuthCookies(cookieIdentifier) {
|
|
|
19
31
|
},
|
|
20
32
|
},
|
|
21
33
|
callbackUrl: {
|
|
22
|
-
name:
|
|
34
|
+
name: names.callback,
|
|
23
35
|
options: {
|
|
24
36
|
httpOnly: true,
|
|
25
37
|
sameSite: "lax",
|
|
@@ -28,7 +40,7 @@ export function createNextAuthCookies(cookieIdentifier) {
|
|
|
28
40
|
},
|
|
29
41
|
},
|
|
30
42
|
csrfToken: {
|
|
31
|
-
name:
|
|
43
|
+
name: names.csrf,
|
|
32
44
|
options: {
|
|
33
45
|
httpOnly: true,
|
|
34
46
|
sameSite: "lax",
|
|
@@ -38,6 +50,15 @@ export function createNextAuthCookies(cookieIdentifier) {
|
|
|
38
50
|
},
|
|
39
51
|
};
|
|
40
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Derive cookie names from the connected database, enabling SSO across apps
|
|
55
|
+
* that share the same auth database. If multiple apps point to the same DB name,
|
|
56
|
+
* they will share the same cookie namespace and thus sessions.
|
|
57
|
+
*/
|
|
58
|
+
export function createNextAuthCookiesFromDb(db, opts) {
|
|
59
|
+
const id = db.getDbName ? db.getDbName() : "anydb";
|
|
60
|
+
return createNextAuthCookies(id, opts);
|
|
61
|
+
}
|
|
41
62
|
// Datomic schema idents
|
|
42
63
|
const USER = {
|
|
43
64
|
id: "anydb.auth.user.v1/id", // uuid identity
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anysoftinc/anydb-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "AnyDB TypeScript SDK for querying and transacting with Datomic databases",
|
|
5
5
|
"main": "dist/client.js",
|
|
6
6
|
"types": "dist/client.d.ts",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"require": "./dist/client.js",
|
|
16
16
|
"types": "./dist/client.d.ts"
|
|
17
17
|
},
|
|
18
|
+
"./auth": {
|
|
19
|
+
"import": "./dist/auth.js",
|
|
20
|
+
"require": "./dist/auth.js",
|
|
21
|
+
"types": "./dist/auth.d.ts"
|
|
22
|
+
},
|
|
18
23
|
"./nextauth-adapter": {
|
|
19
24
|
"import": "./dist/nextauth-adapter.js",
|
|
20
25
|
"require": "./dist/nextauth-adapter.js",
|