@shipdit/cli 0.6.0 → 0.7.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/README.md +110 -22
- package/dist/index.mjs +572 -261
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,10 @@ import fs from "node:fs";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
7
8
|
import { createJiti } from "jiti";
|
|
8
9
|
import { spawn } from "node:child_process";
|
|
10
|
+
import { isDeepStrictEqual } from "node:util";
|
|
9
11
|
|
|
10
12
|
//#region src/lib/errors.ts
|
|
11
13
|
var CliError = class extends Error {
|
|
@@ -438,10 +440,12 @@ const S$1 = (...t) => hc(...t);
|
|
|
438
440
|
const C$1 = (...t) => hc(...t);
|
|
439
441
|
const w$1 = (...t) => hc(...t);
|
|
440
442
|
const T$1 = (...t) => hc(...t);
|
|
441
|
-
|
|
443
|
+
const E$1 = (...t) => hc(...t);
|
|
444
|
+
const D$1 = (...t) => hc(...t);
|
|
445
|
+
function O$1(e) {
|
|
442
446
|
return `${e.replace(/\/+$/, ``)}/api/v1/rpc`;
|
|
443
447
|
}
|
|
444
|
-
function
|
|
448
|
+
function k$1(e) {
|
|
445
449
|
return {
|
|
446
450
|
...e.fetch ? { fetch: e.fetch } : {},
|
|
447
451
|
init: { credentials: e.client === `dashboard` ? `include` : `same-origin` },
|
|
@@ -451,191 +455,225 @@ function D$1(e) {
|
|
|
451
455
|
}
|
|
452
456
|
};
|
|
453
457
|
}
|
|
454
|
-
async function
|
|
458
|
+
async function A$1(e, t) {
|
|
455
459
|
return a$1(await e({ json: t }));
|
|
456
460
|
}
|
|
457
|
-
async function
|
|
461
|
+
async function j$1(e, t) {
|
|
458
462
|
let n = await e({ json: t });
|
|
459
463
|
return {
|
|
460
464
|
items: await a$1(n),
|
|
461
465
|
nextCursor: n.headers.get(`next-cursor`)
|
|
462
466
|
};
|
|
463
467
|
}
|
|
464
|
-
function
|
|
465
|
-
|
|
468
|
+
async function M$1(e, t, n) {
|
|
469
|
+
return a$1(await e({ json: t }, { headers: { "idempotency-key": n } }));
|
|
470
|
+
}
|
|
471
|
+
function N$1(e) {
|
|
472
|
+
let t = O$1(e.baseUrl), n = k$1(e), r = o$1(t, n), i = s$1(t, n), a = c$1(t, n), N = l$1(t, n), P = u$1(t, n), F = d$2(t, n), I = f$2(t, n), L = p$1(t, n), R = m$1(t, n), z = v$1(t, n), B = _$1(t, n), V = h$1(t, n), H = g$1(t, n), U = y$1(t, n), W = D$1(t, n), G = b$1(t, n), K = x$1(t, n), q = S$1(t, n), J = E$1(t, n), Y = C$1(t, n), X = w$1(t, n), Z = T$1(t, n);
|
|
466
473
|
return {
|
|
474
|
+
release: {
|
|
475
|
+
list: (e) => A$1(a.release.list.$post, e),
|
|
476
|
+
get: (e) => A$1(a.release.get.$post, e),
|
|
477
|
+
create: (e, t) => M$1(a.release.create.$post, e, t),
|
|
478
|
+
update: (e, t) => M$1(a.release.update.$post, e, t),
|
|
479
|
+
bindCommit: (e, t) => M$1(a.release.bindCommit.$post, e, t),
|
|
480
|
+
transition: (e, t) => M$1(a.release.transition.$post, e, t),
|
|
481
|
+
completeStage: (e, t) => M$1(a.release.completeStage.$post, e, t),
|
|
482
|
+
ingestEvidence: (e) => A$1(a.release.ingestEvidence.$post, e),
|
|
483
|
+
addEvidence: (e, t) => M$1(a.release.addEvidence.$post, e, t)
|
|
484
|
+
},
|
|
467
485
|
me: {
|
|
468
|
-
get: (e = {}) =>
|
|
469
|
-
feedback: (e) =>
|
|
486
|
+
get: (e = {}) => A$1(r.me.$post, e),
|
|
487
|
+
feedback: (e) => A$1(r.me.feedback.$post, e)
|
|
470
488
|
},
|
|
471
489
|
project: {
|
|
472
|
-
listTransfers: (e = {}) =>
|
|
473
|
-
requestTransfer: (e) =>
|
|
474
|
-
decideTransfer: (e) =>
|
|
475
|
-
list: (e = {}) =>
|
|
476
|
-
create: (e) =>
|
|
477
|
-
update: (e) =>
|
|
478
|
-
archive: (e) =>
|
|
479
|
-
listArchived: (e = {}) =>
|
|
480
|
-
restore: (e) =>
|
|
481
|
-
|
|
482
|
-
|
|
490
|
+
listTransfers: (e = {}) => A$1(i.project.listTransfers.$post, e),
|
|
491
|
+
requestTransfer: (e) => A$1(i.project.requestTransfer.$post, e),
|
|
492
|
+
decideTransfer: (e) => A$1(i.project.decideTransfer.$post, e),
|
|
493
|
+
list: (e = {}) => A$1(i.project.list.$post, e),
|
|
494
|
+
create: (e) => A$1(i.project.create.$post, e),
|
|
495
|
+
update: (e) => A$1(i.project.update.$post, e),
|
|
496
|
+
archive: (e) => A$1(i.project.archive.$post, e),
|
|
497
|
+
listArchived: (e = {}) => A$1(i.project.listArchived.$post, e),
|
|
498
|
+
restore: (e) => A$1(i.project.restore.$post, e),
|
|
499
|
+
access: (e) => A$1(i.project.access.$post, e),
|
|
500
|
+
listMembers: (e) => A$1(i.project.listMembers.$post, e),
|
|
501
|
+
setMember: (e) => A$1(i.project.setMember.$post, e),
|
|
502
|
+
setTeamRole: (e) => A$1(i.project.setTeamRole.$post, e),
|
|
503
|
+
listTeams: (e) => A$1(i.project.listTeams.$post, e),
|
|
504
|
+
setTeams: (e) => A$1(i.project.setTeams.$post, e)
|
|
483
505
|
},
|
|
484
|
-
team: { listMembers: (e) =>
|
|
506
|
+
team: { listMembers: (e) => A$1(Y.team.listMembers.$post, e) },
|
|
485
507
|
environment: {
|
|
486
|
-
list: (e) =>
|
|
487
|
-
create: (e) =>
|
|
488
|
-
update: (e) =>
|
|
489
|
-
archive: (e) =>
|
|
490
|
-
listArchived: (e) =>
|
|
491
|
-
restore: (e) =>
|
|
508
|
+
list: (e) => A$1(N.environment.list.$post, e),
|
|
509
|
+
create: (e) => A$1(N.environment.create.$post, e),
|
|
510
|
+
update: (e) => A$1(N.environment.update.$post, e),
|
|
511
|
+
archive: (e) => A$1(N.environment.archive.$post, e),
|
|
512
|
+
listArchived: (e) => A$1(N.environment.listArchived.$post, e),
|
|
513
|
+
restore: (e) => A$1(N.environment.restore.$post, e)
|
|
492
514
|
},
|
|
493
515
|
flag: {
|
|
494
|
-
list: (e) =>
|
|
495
|
-
get: (e) =>
|
|
496
|
-
create: (e) =>
|
|
497
|
-
update: (e) =>
|
|
498
|
-
archive: (e) =>
|
|
499
|
-
listArchived: (e) =>
|
|
500
|
-
restore: (e) =>
|
|
501
|
-
publishEnvironments: (e) =>
|
|
502
|
-
updateEnvironment: (e) =>
|
|
503
|
-
toggleEnvironment: (e) =>
|
|
504
|
-
listEnvironmentStates: (e) =>
|
|
505
|
-
pull: (e) =>
|
|
506
|
-
diff: (e) =>
|
|
507
|
-
push: (e) =>
|
|
516
|
+
list: (e) => A$1(P.flag.list.$post, e),
|
|
517
|
+
get: (e) => A$1(P.flag.get.$post, e),
|
|
518
|
+
create: (e) => A$1(P.flag.create.$post, e),
|
|
519
|
+
update: (e) => A$1(P.flag.update.$post, e),
|
|
520
|
+
archive: (e) => A$1(P.flag.archive.$post, e),
|
|
521
|
+
listArchived: (e) => A$1(P.flag.listArchived.$post, e),
|
|
522
|
+
restore: (e) => A$1(P.flag.restore.$post, e),
|
|
523
|
+
publishEnvironments: (e) => A$1(P.flag.publishEnvironments.$post, e),
|
|
524
|
+
updateEnvironment: (e) => A$1(P.flag.updateEnvironment.$post, e),
|
|
525
|
+
toggleEnvironment: (e) => A$1(P.flag.toggleEnvironment.$post, e),
|
|
526
|
+
listEnvironmentStates: (e) => A$1(P.flag.listEnvironmentStates.$post, e),
|
|
527
|
+
pull: (e) => A$1(P.flag.pull.$post, e),
|
|
528
|
+
diff: (e) => A$1(P.flag.diff.$post, e),
|
|
529
|
+
push: (e) => A$1(P.flag.push.$post, e)
|
|
508
530
|
},
|
|
509
531
|
apiKey: {
|
|
510
|
-
list: (e = {}) =>
|
|
511
|
-
create: (e) =>
|
|
512
|
-
revoke: (e) =>
|
|
532
|
+
list: (e = {}) => A$1(F.apiKey.list.$post, e),
|
|
533
|
+
create: (e) => A$1(F.apiKey.create.$post, e),
|
|
534
|
+
revoke: (e) => A$1(F.apiKey.revoke.$post, e)
|
|
513
535
|
},
|
|
514
536
|
sdkKey: {
|
|
515
|
-
list: (e = {}) =>
|
|
516
|
-
create: (e) =>
|
|
517
|
-
revoke: (e) =>
|
|
537
|
+
list: (e = {}) => A$1(R.sdkKey.list.$post, e),
|
|
538
|
+
create: (e) => A$1(R.sdkKey.create.$post, e),
|
|
539
|
+
revoke: (e) => A$1(R.sdkKey.revoke.$post, e)
|
|
518
540
|
},
|
|
519
541
|
serviceAccount: {
|
|
520
|
-
list: (e = {}) =>
|
|
521
|
-
get: (e) =>
|
|
522
|
-
create: (e) =>
|
|
523
|
-
update: (e) =>
|
|
524
|
-
disable: (e) =>
|
|
525
|
-
enable: (e) =>
|
|
526
|
-
delete: (e) =>
|
|
527
|
-
createToken: (e) =>
|
|
528
|
-
listTokens: (e) =>
|
|
529
|
-
revokeToken: (e) =>
|
|
530
|
-
rotateToken: (e) =>
|
|
542
|
+
list: (e = {}) => A$1(z.serviceAccount.list.$post, e),
|
|
543
|
+
get: (e) => A$1(z.serviceAccount.get.$post, e),
|
|
544
|
+
create: (e) => A$1(z.serviceAccount.create.$post, e),
|
|
545
|
+
update: (e) => A$1(z.serviceAccount.update.$post, e),
|
|
546
|
+
disable: (e) => A$1(z.serviceAccount.disable.$post, e),
|
|
547
|
+
enable: (e) => A$1(z.serviceAccount.enable.$post, e),
|
|
548
|
+
delete: (e) => A$1(z.serviceAccount.delete.$post, e),
|
|
549
|
+
createToken: (e) => A$1(z.serviceAccount.createToken.$post, e),
|
|
550
|
+
listTokens: (e) => A$1(z.serviceAccount.listTokens.$post, e),
|
|
551
|
+
revokeToken: (e) => A$1(z.serviceAccount.revokeToken.$post, e),
|
|
552
|
+
rotateToken: (e) => A$1(z.serviceAccount.rotateToken.$post, e)
|
|
531
553
|
},
|
|
532
554
|
segment: {
|
|
533
|
-
list: (e) =>
|
|
534
|
-
get: (e) =>
|
|
535
|
-
create: (e) =>
|
|
536
|
-
update: (e) =>
|
|
537
|
-
archive: (e) =>
|
|
538
|
-
listArchived: (e) =>
|
|
539
|
-
restore: (e) =>
|
|
540
|
-
listEnvironmentStates: (e) =>
|
|
541
|
-
updateEnvironment: (e) =>
|
|
555
|
+
list: (e) => A$1(B.segment.list.$post, e),
|
|
556
|
+
get: (e) => A$1(B.segment.get.$post, e),
|
|
557
|
+
create: (e) => A$1(B.segment.create.$post, e),
|
|
558
|
+
update: (e) => A$1(B.segment.update.$post, e),
|
|
559
|
+
archive: (e) => A$1(B.segment.archive.$post, e),
|
|
560
|
+
listArchived: (e) => A$1(B.segment.listArchived.$post, e),
|
|
561
|
+
restore: (e) => A$1(B.segment.restore.$post, e),
|
|
562
|
+
listEnvironmentStates: (e) => A$1(B.segment.listEnvironmentStates.$post, e),
|
|
563
|
+
updateEnvironment: (e) => A$1(B.segment.updateEnvironment.$post, e)
|
|
542
564
|
},
|
|
543
565
|
evaluatedEntity: {
|
|
544
|
-
list: (e) =>
|
|
545
|
-
listPage: (e) =>
|
|
546
|
-
get: (e) =>
|
|
547
|
-
delete: (e) =>
|
|
566
|
+
list: (e) => A$1(V.evaluatedEntity.list.$post, e),
|
|
567
|
+
listPage: (e) => j$1(V.evaluatedEntity.list.$post, e),
|
|
568
|
+
get: (e) => A$1(V.evaluatedEntity.get.$post, e),
|
|
569
|
+
delete: (e) => A$1(V.evaluatedEntity.delete.$post, e)
|
|
548
570
|
},
|
|
549
571
|
evaluationFact: {
|
|
550
|
-
list: (e) =>
|
|
551
|
-
byRule: (e) =>
|
|
552
|
-
orgSummary: (e = {}) =>
|
|
553
|
-
projectSummary: (e) =>
|
|
554
|
-
simulate: (e) =>
|
|
572
|
+
list: (e) => A$1(H.evaluationFact.list.$post, e),
|
|
573
|
+
byRule: (e) => A$1(H.evaluationFact.byRule.$post, e),
|
|
574
|
+
orgSummary: (e = {}) => A$1(H.evaluationFact.orgSummary.$post, e),
|
|
575
|
+
projectSummary: (e) => A$1(H.evaluationFact.projectSummary.$post, e),
|
|
576
|
+
simulate: (e) => A$1(H.evaluationFact.simulate.$post, e)
|
|
555
577
|
},
|
|
556
578
|
snapshot: {
|
|
557
|
-
publish: (e) =>
|
|
558
|
-
listOutbox: (e = {}) =>
|
|
559
|
-
listOutboxPage: (e = {}) =>
|
|
560
|
-
requeue: (e) =>
|
|
561
|
-
rebuild: (e) =>
|
|
562
|
-
listPublications: (e) =>
|
|
563
|
-
listPublicationsPage: (e) =>
|
|
579
|
+
publish: (e) => A$1(U.snapshot.publish.$post, e),
|
|
580
|
+
listOutbox: (e = {}) => A$1(U.snapshot.outbox.list.$post, e),
|
|
581
|
+
listOutboxPage: (e = {}) => j$1(U.snapshot.outbox.list.$post, e),
|
|
582
|
+
requeue: (e) => A$1(U.snapshot.outbox.requeue.$post, e),
|
|
583
|
+
rebuild: (e) => A$1(U.snapshot.rebuild.$post, e),
|
|
584
|
+
listPublications: (e) => A$1(U.snapshot.publications.list.$post, e),
|
|
585
|
+
listPublicationsPage: (e) => j$1(U.snapshot.publications.list.$post, e)
|
|
586
|
+
},
|
|
587
|
+
event: { publish: (e, t) => M$1(W.event.publish.$post, e, t) },
|
|
588
|
+
eventWebhook: {
|
|
589
|
+
eventTypes: (e) => A$1(W.eventWebhook.eventTypes.$post, e),
|
|
590
|
+
list: (e) => A$1(W.eventWebhook.list.$post, e),
|
|
591
|
+
create: (e) => A$1(W.eventWebhook.create.$post, e),
|
|
592
|
+
update: (e) => A$1(W.eventWebhook.update.$post, e),
|
|
593
|
+
delete: (e) => A$1(W.eventWebhook.delete.$post, e),
|
|
594
|
+
test: (e, t) => M$1(W.eventWebhook.test.$post, e, t),
|
|
595
|
+
deliveries: (e) => A$1(W.eventWebhook.deliveries.$post, e),
|
|
596
|
+
attempts: (e) => A$1(W.eventWebhook.attempts.$post, e),
|
|
597
|
+
redeliver: (e, t) => M$1(W.eventWebhook.redeliver.$post, e, t),
|
|
598
|
+
usage: (e) => A$1(W.eventWebhook.usage.$post, e)
|
|
564
599
|
},
|
|
565
600
|
snapshotWebhook: {
|
|
566
|
-
list: (e) =>
|
|
567
|
-
create: (e) =>
|
|
568
|
-
update: (e) =>
|
|
569
|
-
delete: (e) =>
|
|
570
|
-
test: (e) =>
|
|
601
|
+
list: (e) => A$1(G.snapshotWebhook.list.$post, e),
|
|
602
|
+
create: (e) => A$1(G.snapshotWebhook.create.$post, e),
|
|
603
|
+
update: (e) => A$1(G.snapshotWebhook.update.$post, e),
|
|
604
|
+
delete: (e) => A$1(G.snapshotWebhook.delete.$post, e),
|
|
605
|
+
test: (e) => A$1(G.snapshotWebhook.test.$post, e)
|
|
571
606
|
},
|
|
572
|
-
device: { authorize: (e) =>
|
|
607
|
+
device: { authorize: (e) => A$1(K.device.authorize.$post, e) },
|
|
573
608
|
billing: {
|
|
574
|
-
get: (e = {}) =>
|
|
575
|
-
|
|
576
|
-
|
|
609
|
+
get: (e = {}) => A$1(q.billing.get.$post, e),
|
|
610
|
+
updateUsage: (e) => A$1(q.billing.updateUsage.$post, e),
|
|
611
|
+
attach: (e) => A$1(q.billing.attach.$post, e),
|
|
612
|
+
openPortal: (e) => A$1(q.billing.openPortal.$post, e)
|
|
577
613
|
},
|
|
578
|
-
usage: { get: (e = {}) =>
|
|
614
|
+
usage: { get: (e = {}) => A$1(J.usage.get.$post, e) },
|
|
579
615
|
approval: {
|
|
580
|
-
listPolicies: (e = {}) =>
|
|
581
|
-
createPolicy: (e) =>
|
|
582
|
-
updatePolicy: (e) =>
|
|
583
|
-
deletePolicy: (e) =>
|
|
584
|
-
listRequests: (e = {}) =>
|
|
585
|
-
listRequestsPage: (e = {}) =>
|
|
586
|
-
get: (e) =>
|
|
587
|
-
approve: (e) =>
|
|
588
|
-
reject: (e) =>
|
|
589
|
-
cancel: (e) =>
|
|
616
|
+
listPolicies: (e = {}) => A$1(I.approval.listPolicies.$post, e),
|
|
617
|
+
createPolicy: (e) => A$1(I.approval.createPolicy.$post, e),
|
|
618
|
+
updatePolicy: (e) => A$1(I.approval.updatePolicy.$post, e),
|
|
619
|
+
deletePolicy: (e) => A$1(I.approval.deletePolicy.$post, e),
|
|
620
|
+
listRequests: (e = {}) => A$1(I.approval.listRequests.$post, e),
|
|
621
|
+
listRequestsPage: (e = {}) => j$1(I.approval.listRequests.$post, e),
|
|
622
|
+
get: (e) => A$1(I.approval.get.$post, e),
|
|
623
|
+
approve: (e) => A$1(I.approval.approve.$post, e),
|
|
624
|
+
reject: (e) => A$1(I.approval.reject.$post, e),
|
|
625
|
+
cancel: (e) => A$1(I.approval.cancel.$post, e)
|
|
590
626
|
},
|
|
591
627
|
audit: {
|
|
592
|
-
list: (e = {}) =>
|
|
593
|
-
get: (e) =>
|
|
594
|
-
actions: (e = {}) =>
|
|
595
|
-
export: (e) =>
|
|
596
|
-
getSettings: (e = {}) =>
|
|
597
|
-
updateSettings: (e) =>
|
|
598
|
-
listDestinations: (e = {}) =>
|
|
599
|
-
createDestination: (e) =>
|
|
600
|
-
updateDestination: (e) =>
|
|
601
|
-
deleteDestination: (e) =>
|
|
602
|
-
testDestination: (e) =>
|
|
628
|
+
list: (e = {}) => A$1(L.audit.list.$post, e),
|
|
629
|
+
get: (e) => A$1(L.audit.get.$post, e),
|
|
630
|
+
actions: (e = {}) => A$1(L.audit.actions.$post, e),
|
|
631
|
+
export: (e) => A$1(L.audit.export.$post, e),
|
|
632
|
+
getSettings: (e = {}) => A$1(L.audit.getSettings.$post, e),
|
|
633
|
+
updateSettings: (e) => A$1(L.audit.updateSettings.$post, e),
|
|
634
|
+
listDestinations: (e = {}) => A$1(L.audit.listDestinations.$post, e),
|
|
635
|
+
createDestination: (e) => A$1(L.audit.createDestination.$post, e),
|
|
636
|
+
updateDestination: (e) => A$1(L.audit.updateDestination.$post, e),
|
|
637
|
+
deleteDestination: (e) => A$1(L.audit.deleteDestination.$post, e),
|
|
638
|
+
testDestination: (e) => A$1(L.audit.testDestination.$post, e)
|
|
603
639
|
},
|
|
604
640
|
sso: {
|
|
605
|
-
getSettings: (e = {}) =>
|
|
606
|
-
listProviders: (e = {}) =>
|
|
607
|
-
updateAllowedDomains: (e) =>
|
|
608
|
-
setEnforcement: (e) =>
|
|
609
|
-
setRequireTwoFactor: (e) =>
|
|
641
|
+
getSettings: (e = {}) => A$1(X.sso.getSettings.$post, e),
|
|
642
|
+
listProviders: (e = {}) => A$1(X.sso.listProviders.$post, e),
|
|
643
|
+
updateAllowedDomains: (e) => A$1(X.sso.updateAllowedDomains.$post, e),
|
|
644
|
+
setEnforcement: (e) => A$1(X.sso.setEnforcement.$post, e),
|
|
645
|
+
setRequireTwoFactor: (e) => A$1(X.sso.setRequireTwoFactor.$post, e)
|
|
610
646
|
},
|
|
611
647
|
scim: {
|
|
612
|
-
getConnection: (e = {}) =>
|
|
613
|
-
createConnection: (e = { creationRequestId: crypto.randomUUID() }) =>
|
|
614
|
-
rotateCredential: (e) =>
|
|
615
|
-
revokeCredential: (e) =>
|
|
616
|
-
decommissionConnection: (e) =>
|
|
648
|
+
getConnection: (e = {}) => A$1(Z.scim.getConnection.$post, e),
|
|
649
|
+
createConnection: (e = { creationRequestId: crypto.randomUUID() }) => A$1(Z.scim.createConnection.$post, e),
|
|
650
|
+
rotateCredential: (e) => A$1(Z.scim.rotateCredential.$post, e),
|
|
651
|
+
revokeCredential: (e) => A$1(Z.scim.revokeCredential.$post, e),
|
|
652
|
+
decommissionConnection: (e) => A$1(Z.scim.decommissionConnection.$post, e)
|
|
617
653
|
},
|
|
618
654
|
raw: {
|
|
619
655
|
me: r,
|
|
620
656
|
project: i,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
657
|
+
release: a,
|
|
658
|
+
environment: N,
|
|
659
|
+
flag: P,
|
|
660
|
+
apiKey: F,
|
|
661
|
+
approval: I,
|
|
662
|
+
audit: L,
|
|
663
|
+
sdkKey: R,
|
|
664
|
+
serviceAccount: z,
|
|
665
|
+
segment: B,
|
|
666
|
+
evaluatedEntity: V,
|
|
667
|
+
evaluationFact: H,
|
|
668
|
+
snapshot: U,
|
|
669
|
+
snapshotWebhook: G,
|
|
670
|
+
eventWebhook: W,
|
|
671
|
+
device: K,
|
|
672
|
+
billing: q,
|
|
673
|
+
usage: J,
|
|
674
|
+
team: Y,
|
|
675
|
+
sso: X,
|
|
676
|
+
scim: Z
|
|
639
677
|
}
|
|
640
678
|
};
|
|
641
679
|
}
|
|
@@ -779,7 +817,7 @@ var BetterAuthError = class extends Error {
|
|
|
779
817
|
};
|
|
780
818
|
|
|
781
819
|
//#endregion
|
|
782
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
820
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/access/access.mjs
|
|
783
821
|
function unknownResourceResponse(requestedResource) {
|
|
784
822
|
return {
|
|
785
823
|
success: false,
|
|
@@ -856,7 +894,7 @@ function createAccessControl(s) {
|
|
|
856
894
|
}
|
|
857
895
|
|
|
858
896
|
//#endregion
|
|
859
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
897
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/two-factor/error-code.mjs
|
|
860
898
|
const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
|
|
861
899
|
OTP_NOT_ENABLED: "OTP not enabled",
|
|
862
900
|
OTP_NOT_CONFIGURED: "OTP is not available",
|
|
@@ -874,11 +912,11 @@ const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
|
|
|
874
912
|
});
|
|
875
913
|
|
|
876
914
|
//#endregion
|
|
877
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
915
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/package.mjs
|
|
878
916
|
var version = "1.7.7";
|
|
879
917
|
|
|
880
918
|
//#endregion
|
|
881
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
919
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/version.mjs
|
|
882
920
|
const PACKAGE_VERSION$3 = version;
|
|
883
921
|
|
|
884
922
|
//#endregion
|
|
@@ -914,7 +952,7 @@ function isSafeUrlScheme(value) {
|
|
|
914
952
|
}
|
|
915
953
|
|
|
916
954
|
//#endregion
|
|
917
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
955
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/two-factor/client.mjs
|
|
918
956
|
const twoFactorClient = (options) => {
|
|
919
957
|
return {
|
|
920
958
|
id: "two-factor",
|
|
@@ -952,7 +990,7 @@ const twoFactorClient = (options) => {
|
|
|
952
990
|
};
|
|
953
991
|
|
|
954
992
|
//#endregion
|
|
955
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
993
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/admin/access/statement.mjs
|
|
956
994
|
const defaultStatements$1 = {
|
|
957
995
|
user: [
|
|
958
996
|
"create",
|
|
@@ -1003,7 +1041,7 @@ const defaultRoles$1 = {
|
|
|
1003
1041
|
};
|
|
1004
1042
|
|
|
1005
1043
|
//#endregion
|
|
1006
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1044
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/admin/error-codes.mjs
|
|
1007
1045
|
const ADMIN_ERROR_CODES = defineErrorCodes({
|
|
1008
1046
|
FAILED_TO_CREATE_USER: "Failed to create user",
|
|
1009
1047
|
USER_ALREADY_EXISTS: "User already exists.",
|
|
@@ -1095,7 +1133,7 @@ const ENV = Object.freeze({
|
|
|
1095
1133
|
});
|
|
1096
1134
|
|
|
1097
1135
|
//#endregion
|
|
1098
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1136
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/utils/url.mjs
|
|
1099
1137
|
const SLASH_CHAR_CODE = "/".charCodeAt(0);
|
|
1100
1138
|
function trimTrailingSlashes(value) {
|
|
1101
1139
|
let end = value.length;
|
|
@@ -1174,7 +1212,7 @@ function getOrigin(url) {
|
|
|
1174
1212
|
}
|
|
1175
1213
|
|
|
1176
1214
|
//#endregion
|
|
1177
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1215
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/admin/has-permission.mjs
|
|
1178
1216
|
const hasPermission = (input) => {
|
|
1179
1217
|
if (input.userId && input.options?.adminUserIds?.includes(input.userId)) return true;
|
|
1180
1218
|
if (!input.permissions) return false;
|
|
@@ -1776,7 +1814,7 @@ const createFetch = (config) => {
|
|
|
1776
1814
|
};
|
|
1777
1815
|
|
|
1778
1816
|
//#endregion
|
|
1779
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1817
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/parser.mjs
|
|
1780
1818
|
const PROTO_POLLUTION_PATTERNS = {
|
|
1781
1819
|
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
1782
1820
|
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
@@ -1846,7 +1884,7 @@ function parseJSON(value, options = { strict: true }) {
|
|
|
1846
1884
|
}
|
|
1847
1885
|
|
|
1848
1886
|
//#endregion
|
|
1849
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1887
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/organization/access/statement.mjs
|
|
1850
1888
|
const defaultStatements = {
|
|
1851
1889
|
organization: ["update", "delete"],
|
|
1852
1890
|
member: [
|
|
@@ -1922,7 +1960,7 @@ const defaultRoles = {
|
|
|
1922
1960
|
};
|
|
1923
1961
|
|
|
1924
1962
|
//#endregion
|
|
1925
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1963
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/organization/permission.mjs
|
|
1926
1964
|
const hasPermissionFn = (input, acRoles) => {
|
|
1927
1965
|
if (!input.permissions) return false;
|
|
1928
1966
|
const roles = input.role.split(",");
|
|
@@ -1935,7 +1973,7 @@ const hasPermissionFn = (input, acRoles) => {
|
|
|
1935
1973
|
};
|
|
1936
1974
|
|
|
1937
1975
|
//#endregion
|
|
1938
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
1976
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/organization/error-codes.mjs
|
|
1939
1977
|
const ORGANIZATION_ERROR_CODES = defineErrorCodes({
|
|
1940
1978
|
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION: "You are not allowed to create a new organization",
|
|
1941
1979
|
YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS: "You have reached the maximum number of organizations",
|
|
@@ -2060,6 +2098,8 @@ const t$1 = createAccessControl({
|
|
|
2060
2098
|
evaluated_entity: [`read`, `delete`],
|
|
2061
2099
|
snapshot: [`read`],
|
|
2062
2100
|
snapshot_webhook: [`read`, `manage`],
|
|
2101
|
+
event_webhook: [`read`, `manage`],
|
|
2102
|
+
customer_event: [`publish`],
|
|
2063
2103
|
billing: [`read`, `manage`],
|
|
2064
2104
|
sso: [
|
|
2065
2105
|
`read`,
|
|
@@ -2088,6 +2128,7 @@ const n$1 = {
|
|
|
2088
2128
|
flag: [`read`],
|
|
2089
2129
|
evaluated_entity: [`read`],
|
|
2090
2130
|
snapshot_webhook: [`read`],
|
|
2131
|
+
event_webhook: [`read`],
|
|
2091
2132
|
billing: [`read`],
|
|
2092
2133
|
approval_policy: [`read`],
|
|
2093
2134
|
approval_request: [`read`]
|
|
@@ -2112,6 +2153,7 @@ const n$1 = {
|
|
|
2112
2153
|
],
|
|
2113
2154
|
evaluated_entity: [`read`],
|
|
2114
2155
|
snapshot_webhook: [`read`],
|
|
2156
|
+
event_webhook: [`read`],
|
|
2115
2157
|
billing: [`read`],
|
|
2116
2158
|
approval_policy: [`read`],
|
|
2117
2159
|
approval_request: [`read`]
|
|
@@ -2176,6 +2218,8 @@ const n$1 = {
|
|
|
2176
2218
|
evaluated_entity: [`read`, `delete`],
|
|
2177
2219
|
snapshot: [`read`],
|
|
2178
2220
|
snapshot_webhook: [`read`, `manage`],
|
|
2221
|
+
event_webhook: [`read`, `manage`],
|
|
2222
|
+
customer_event: [`publish`],
|
|
2179
2223
|
billing: [`read`, `manage`],
|
|
2180
2224
|
sso: [`read`, `manage`],
|
|
2181
2225
|
service_account: [
|
|
@@ -2251,6 +2295,8 @@ const n$1 = {
|
|
|
2251
2295
|
evaluated_entity: [`read`, `delete`],
|
|
2252
2296
|
snapshot: [`read`],
|
|
2253
2297
|
snapshot_webhook: [`read`, `manage`],
|
|
2298
|
+
event_webhook: [`read`, `manage`],
|
|
2299
|
+
customer_event: [`publish`],
|
|
2254
2300
|
billing: [`read`, `manage`],
|
|
2255
2301
|
sso: [
|
|
2256
2302
|
`read`,
|
|
@@ -2273,7 +2319,7 @@ const n$1 = {
|
|
|
2273
2319
|
};
|
|
2274
2320
|
|
|
2275
2321
|
//#endregion
|
|
2276
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2322
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
2277
2323
|
const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
2278
2324
|
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
2279
2325
|
var WindowBroadcastChannel = class {
|
|
@@ -2497,7 +2543,7 @@ let onMount = ($store, initialize) => {
|
|
|
2497
2543
|
};
|
|
2498
2544
|
|
|
2499
2545
|
//#endregion
|
|
2500
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2546
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/equality.mjs
|
|
2501
2547
|
function isPlainObject(value) {
|
|
2502
2548
|
if (typeof value !== "object" || value === null) return false;
|
|
2503
2549
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -2538,7 +2584,7 @@ function withEquality(store, isEqual) {
|
|
|
2538
2584
|
}
|
|
2539
2585
|
|
|
2540
2586
|
//#endregion
|
|
2541
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2587
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
2542
2588
|
const kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
2543
2589
|
var WindowFocusManager = class {
|
|
2544
2590
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -2568,7 +2614,7 @@ function getGlobalFocusManager() {
|
|
|
2568
2614
|
}
|
|
2569
2615
|
|
|
2570
2616
|
//#endregion
|
|
2571
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2617
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/online-manager.mjs
|
|
2572
2618
|
const kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
2573
2619
|
var WindowOnlineManager = class {
|
|
2574
2620
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -2601,7 +2647,7 @@ function getGlobalOnlineManager() {
|
|
|
2601
2647
|
}
|
|
2602
2648
|
|
|
2603
2649
|
//#endregion
|
|
2604
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2650
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/query-atom.mjs
|
|
2605
2651
|
const kAuthQuery = Symbol.for("better-auth:auth-query");
|
|
2606
2652
|
function createAuthQueryAtom(initialValue) {
|
|
2607
2653
|
const queryAtom = /* @__PURE__ */ atom(initialValue);
|
|
@@ -2610,7 +2656,7 @@ function createAuthQueryAtom(initialValue) {
|
|
|
2610
2656
|
}
|
|
2611
2657
|
|
|
2612
2658
|
//#endregion
|
|
2613
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2659
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/query.mjs
|
|
2614
2660
|
const isServer$1 = () => typeof window === "undefined";
|
|
2615
2661
|
function isAuthQueryStateEqual(a, b) {
|
|
2616
2662
|
return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
|
|
@@ -2741,7 +2787,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
2741
2787
|
};
|
|
2742
2788
|
|
|
2743
2789
|
//#endregion
|
|
2744
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2790
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
2745
2791
|
const now = () => Math.floor(Date.now() / 1e3);
|
|
2746
2792
|
/**
|
|
2747
2793
|
* Rate limit: don't refetch on focus if a session request was made within this many seconds
|
|
@@ -2869,7 +2915,7 @@ function createSessionRefreshManager(opts) {
|
|
|
2869
2915
|
}
|
|
2870
2916
|
|
|
2871
2917
|
//#endregion
|
|
2872
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2918
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
2873
2919
|
const redirectPlugin = {
|
|
2874
2920
|
id: "redirect",
|
|
2875
2921
|
name: "Redirect",
|
|
@@ -2885,7 +2931,7 @@ const redirectPlugin = {
|
|
|
2885
2931
|
};
|
|
2886
2932
|
|
|
2887
2933
|
//#endregion
|
|
2888
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
2934
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/session-atom.mjs
|
|
2889
2935
|
const isServer = () => typeof window === "undefined";
|
|
2890
2936
|
const SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
|
|
2891
2937
|
function hydrateSessionAtom(sessionAtom, session) {
|
|
@@ -3060,7 +3106,7 @@ function getSessionAtom($fetch, options) {
|
|
|
3060
3106
|
}
|
|
3061
3107
|
|
|
3062
3108
|
//#endregion
|
|
3063
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3109
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/config.mjs
|
|
3064
3110
|
const resolvePublicAuthUrl = (basePath) => {
|
|
3065
3111
|
if (typeof process === "undefined") return void 0;
|
|
3066
3112
|
const path = basePath ?? "/api/auth";
|
|
@@ -3166,7 +3212,7 @@ const getClientConfig = (options, loadEnv) => {
|
|
|
3166
3212
|
};
|
|
3167
3213
|
|
|
3168
3214
|
//#endregion
|
|
3169
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3215
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
3170
3216
|
function isAtom(value) {
|
|
3171
3217
|
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
3172
3218
|
}
|
|
@@ -3186,7 +3232,7 @@ function toKebabCase(input) {
|
|
|
3186
3232
|
}
|
|
3187
3233
|
|
|
3188
3234
|
//#endregion
|
|
3189
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3235
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/proxy.mjs
|
|
3190
3236
|
function getMethod(path, knownPathMethods, args) {
|
|
3191
3237
|
const method = knownPathMethods[path];
|
|
3192
3238
|
const { fetchOptions, query: _query, ...body } = args || {};
|
|
@@ -3262,7 +3308,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
3262
3308
|
}
|
|
3263
3309
|
|
|
3264
3310
|
//#endregion
|
|
3265
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3311
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/client/vanilla.mjs
|
|
3266
3312
|
function createAuthClient(options) {
|
|
3267
3313
|
const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
3268
3314
|
const resolvedHooks = {};
|
|
@@ -3277,7 +3323,7 @@ function createAuthClient(options) {
|
|
|
3277
3323
|
}
|
|
3278
3324
|
|
|
3279
3325
|
//#endregion
|
|
3280
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3326
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/additional-fields/client.mjs
|
|
3281
3327
|
const inferAdditionalFields = (schema) => {
|
|
3282
3328
|
return {
|
|
3283
3329
|
id: "additional-fields-client",
|
|
@@ -3287,7 +3333,7 @@ const inferAdditionalFields = (schema) => {
|
|
|
3287
3333
|
};
|
|
3288
3334
|
|
|
3289
3335
|
//#endregion
|
|
3290
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3336
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/admin/client.mjs
|
|
3291
3337
|
const adminClient = (options) => {
|
|
3292
3338
|
const roles = {
|
|
3293
3339
|
admin: adminAc$1,
|
|
@@ -3322,7 +3368,7 @@ const adminClient = (options) => {
|
|
|
3322
3368
|
};
|
|
3323
3369
|
|
|
3324
3370
|
//#endregion
|
|
3325
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3371
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
|
|
3326
3372
|
const deviceAuthorizationClient = () => {
|
|
3327
3373
|
return {
|
|
3328
3374
|
id: "device-authorization",
|
|
@@ -3339,7 +3385,7 @@ const deviceAuthorizationClient = () => {
|
|
|
3339
3385
|
};
|
|
3340
3386
|
|
|
3341
3387
|
//#endregion
|
|
3342
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.
|
|
3388
|
+
//#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.5_drizzle-orm@1.0.0-rc._8ef4619ff178d531df1451d091680cc1/node_modules/better-auth/dist/plugins/organization/client.mjs
|
|
3343
3389
|
/**
|
|
3344
3390
|
* Using the same `hasPermissionFn` function, but without the need for a `ctx` parameter or the `organizationId` parameter.
|
|
3345
3391
|
*/
|
|
@@ -3434,7 +3480,7 @@ const organizationClient = (options) => {
|
|
|
3434
3480
|
};
|
|
3435
3481
|
|
|
3436
3482
|
//#endregion
|
|
3437
|
-
//#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.7_@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-
|
|
3483
|
+
//#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.7_@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fet_72057e843799b0c86a3fe30aeb49ac2b/node_modules/@better-auth/api-key/dist/version-CUtTQbZf.mjs
|
|
3438
3484
|
const API_KEY_ERROR_CODES = defineErrorCodes({
|
|
3439
3485
|
INVALID_METADATA_TYPE: "metadata must be an object or undefined",
|
|
3440
3486
|
REFILL_AMOUNT_AND_INTERVAL_REQUIRED: "refillAmount is required when refillInterval is provided",
|
|
@@ -3471,7 +3517,7 @@ const API_KEY_ERROR_CODES = defineErrorCodes({
|
|
|
3471
3517
|
const PACKAGE_VERSION$2 = "1.7.7";
|
|
3472
3518
|
|
|
3473
3519
|
//#endregion
|
|
3474
|
-
//#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.7_@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-
|
|
3520
|
+
//#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.7_@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fet_72057e843799b0c86a3fe30aeb49ac2b/node_modules/@better-auth/api-key/dist/client.mjs
|
|
3475
3521
|
const apiKeyClient = () => {
|
|
3476
3522
|
return {
|
|
3477
3523
|
id: "api-key",
|
|
@@ -3487,7 +3533,7 @@ const apiKeyClient = () => {
|
|
|
3487
3533
|
};
|
|
3488
3534
|
|
|
3489
3535
|
//#endregion
|
|
3490
|
-
//#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.
|
|
3536
|
+
//#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.7_bb9d362000213fa473d66cafce218d0a/node_modules/@better-auth/passkey/dist/version-Bx477_EO.mjs
|
|
3491
3537
|
const PASSKEY_ERROR_CODES = defineErrorCodes({
|
|
3492
3538
|
CHALLENGE_NOT_FOUND: "Challenge not found",
|
|
3493
3539
|
YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: "You are not allowed to register this passkey",
|
|
@@ -3977,7 +4023,7 @@ async function startAuthentication(options) {
|
|
|
3977
4023
|
}
|
|
3978
4024
|
|
|
3979
4025
|
//#endregion
|
|
3980
|
-
//#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.
|
|
4026
|
+
//#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.7_bb9d362000213fa473d66cafce218d0a/node_modules/@better-auth/passkey/dist/client.mjs
|
|
3981
4027
|
const getPasskeyActions = ($fetch, { $listPasskeys, $store }) => {
|
|
3982
4028
|
const signInPasskey = async (opts, options) => {
|
|
3983
4029
|
const response = await $fetch("/passkey/generate-authenticate-options", {
|
|
@@ -4179,11 +4225,11 @@ const passkeyClient = () => {
|
|
|
4179
4225
|
};
|
|
4180
4226
|
|
|
4181
4227
|
//#endregion
|
|
4182
|
-
//#region ../../node_modules/.pnpm/@better-auth+sso@1.7.
|
|
4228
|
+
//#region ../../node_modules/.pnpm/@better-auth+sso@1.7.7_b7f969b8f4178e26300409b5e56227c3/node_modules/@better-auth/sso/dist/version-DFla2W8i.mjs
|
|
4183
4229
|
const PACKAGE_VERSION = "1.7.7";
|
|
4184
4230
|
|
|
4185
4231
|
//#endregion
|
|
4186
|
-
//#region ../../node_modules/.pnpm/@better-auth+sso@1.7.
|
|
4232
|
+
//#region ../../node_modules/.pnpm/@better-auth+sso@1.7.7_b7f969b8f4178e26300409b5e56227c3/node_modules/@better-auth/sso/dist/client.mjs
|
|
4187
4233
|
const ssoClient = (options) => {
|
|
4188
4234
|
return {
|
|
4189
4235
|
id: "sso-client",
|
|
@@ -4301,7 +4347,7 @@ async function createCliApiClient(runtime) {
|
|
|
4301
4347
|
sessionToken,
|
|
4302
4348
|
orgSlug: runtime.org
|
|
4303
4349
|
});
|
|
4304
|
-
const client =
|
|
4350
|
+
const client = N$1({
|
|
4305
4351
|
baseUrl: runtime.apiUrl,
|
|
4306
4352
|
client: "cli",
|
|
4307
4353
|
getHeaders: () => {
|
|
@@ -4582,44 +4628,38 @@ const g = z.object({
|
|
|
4582
4628
|
segmentId: z.string().min(1),
|
|
4583
4629
|
operator: z.enum([`in`, `not_in`]).optional()
|
|
4584
4630
|
});
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
]
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
for (let n of e) v(n) > 8 && t.addIssue({
|
|
4603
|
-
code: `custom`,
|
|
4604
|
-
message: `condition groups cannot nest more than 8 levels`
|
|
4605
|
-
});
|
|
4606
|
-
}
|
|
4607
|
-
const b = z.object({
|
|
4631
|
+
function _(t) {
|
|
4632
|
+
return z.lazy(() => z.union([
|
|
4633
|
+
h,
|
|
4634
|
+
m,
|
|
4635
|
+
g,
|
|
4636
|
+
d,
|
|
4637
|
+
f,
|
|
4638
|
+
p,
|
|
4639
|
+
...t < 8 ? [z.object({
|
|
4640
|
+
kind: z.literal(`group`),
|
|
4641
|
+
op: z.enum([`and`, `or`]),
|
|
4642
|
+
conditions: z.array(_(t + 1)).min(1)
|
|
4643
|
+
})] : []
|
|
4644
|
+
]));
|
|
4645
|
+
}
|
|
4646
|
+
const v = _(0);
|
|
4647
|
+
const y = z.object({
|
|
4608
4648
|
id: z.string().min(1),
|
|
4609
4649
|
description: z.string().optional(),
|
|
4610
|
-
conditions: z.array(
|
|
4650
|
+
conditions: z.array(v),
|
|
4611
4651
|
serve: u
|
|
4612
|
-
})
|
|
4613
|
-
const
|
|
4652
|
+
});
|
|
4653
|
+
const b = z.object({
|
|
4614
4654
|
id: z.string().min(1),
|
|
4615
|
-
conditions: z.array(
|
|
4616
|
-
})
|
|
4617
|
-
const
|
|
4618
|
-
const
|
|
4655
|
+
conditions: z.array(v).min(1)
|
|
4656
|
+
});
|
|
4657
|
+
const x = z.object({ projectId: z.string().min(1) });
|
|
4658
|
+
const S = z.object({
|
|
4619
4659
|
projectId: z.string().min(1),
|
|
4620
4660
|
key: z.string().min(1)
|
|
4621
4661
|
});
|
|
4622
|
-
const
|
|
4662
|
+
const C = z.object({
|
|
4623
4663
|
projectId: z.string().min(1),
|
|
4624
4664
|
key: o,
|
|
4625
4665
|
name: z.string().min(1),
|
|
@@ -4634,7 +4674,7 @@ const w = z.object({
|
|
|
4634
4674
|
message: `variant flag requires a non-empty variants array`
|
|
4635
4675
|
});
|
|
4636
4676
|
});
|
|
4637
|
-
const
|
|
4677
|
+
const w = z.object({
|
|
4638
4678
|
expectedVersion: z.number().int().positive().optional(),
|
|
4639
4679
|
flagId: z.string().min(1),
|
|
4640
4680
|
key: o.optional(),
|
|
@@ -4644,37 +4684,37 @@ const T = z.object({
|
|
|
4644
4684
|
variants: z.array(z.string()).nullable().optional(),
|
|
4645
4685
|
tags: z.array(z.string()).optional()
|
|
4646
4686
|
});
|
|
4647
|
-
const
|
|
4648
|
-
const
|
|
4649
|
-
const
|
|
4650
|
-
const
|
|
4687
|
+
const T = z.object({ flagId: z.string().min(1) });
|
|
4688
|
+
const E = z.object({ projectId: z.string().min(1) });
|
|
4689
|
+
const D = z.object({ flagId: z.string().min(1) });
|
|
4690
|
+
const O = z.object({
|
|
4651
4691
|
expectedVersion: z.number().int().positive().optional(),
|
|
4652
4692
|
flagId: z.string().min(1),
|
|
4653
4693
|
environmentId: z.string().min(1),
|
|
4654
4694
|
enabled: z.boolean().optional(),
|
|
4655
|
-
rules: z.array(
|
|
4695
|
+
rules: z.array(y).optional(),
|
|
4656
4696
|
fallthrough: u.optional()
|
|
4657
4697
|
});
|
|
4658
|
-
const
|
|
4698
|
+
const k = z.object({
|
|
4659
4699
|
flagId: z.string().min(1),
|
|
4660
4700
|
environments: z.array(z.object({
|
|
4661
4701
|
environmentId: z.string().min(1),
|
|
4662
4702
|
expectedVersion: z.number().int().positive()
|
|
4663
4703
|
})).min(1).refine((e) => new Set(e.map((e) => e.environmentId)).size === e.length, `Duplicate environments`)
|
|
4664
4704
|
});
|
|
4665
|
-
const
|
|
4705
|
+
const A = z.object({
|
|
4666
4706
|
expectedVersion: z.number().int().positive().optional(),
|
|
4667
4707
|
flagId: z.string().min(1),
|
|
4668
4708
|
environmentId: z.string().min(1),
|
|
4669
4709
|
enabled: z.boolean()
|
|
4670
4710
|
});
|
|
4671
|
-
const
|
|
4672
|
-
const
|
|
4673
|
-
function
|
|
4711
|
+
const j = z.object({ flagId: z.string().min(1) });
|
|
4712
|
+
const M = z.enum([`active`, `deprecated`]);
|
|
4713
|
+
function N(e) {
|
|
4674
4714
|
let t = Object.getPrototypeOf(e);
|
|
4675
4715
|
return t === Object.prototype || t === null;
|
|
4676
4716
|
}
|
|
4677
|
-
function
|
|
4717
|
+
function P(e, t) {
|
|
4678
4718
|
if (e === null) return !0;
|
|
4679
4719
|
switch (typeof e) {
|
|
4680
4720
|
case `boolean`:
|
|
@@ -4682,13 +4722,19 @@ function F(e, t) {
|
|
|
4682
4722
|
case `number`: return Number.isFinite(e);
|
|
4683
4723
|
case `object`: {
|
|
4684
4724
|
let n = t ?? /* @__PURE__ */ new WeakSet();
|
|
4685
|
-
|
|
4725
|
+
if (n.has(e)) return !1;
|
|
4726
|
+
n.add(e);
|
|
4727
|
+
try {
|
|
4728
|
+
return Array.isArray(e) ? e.every((e) => P(e, n)) : !N(e) || Object.getOwnPropertySymbols(e).length > 0 ? !1 : Object.keys(e).every((t) => P(e[t], n));
|
|
4729
|
+
} finally {
|
|
4730
|
+
n.delete(e);
|
|
4731
|
+
}
|
|
4686
4732
|
}
|
|
4687
4733
|
default: return !1;
|
|
4688
4734
|
}
|
|
4689
4735
|
}
|
|
4690
|
-
const
|
|
4691
|
-
function
|
|
4736
|
+
const F = z.custom(P, { message: `default must be JSON-serializable` });
|
|
4737
|
+
function I(e, t) {
|
|
4692
4738
|
switch (e.type) {
|
|
4693
4739
|
case `boolean`:
|
|
4694
4740
|
typeof e.default != `boolean` && t.addIssue({
|
|
@@ -4717,43 +4763,177 @@ function L(e, t) {
|
|
|
4717
4763
|
});
|
|
4718
4764
|
break;
|
|
4719
4765
|
}
|
|
4720
|
-
case `json`:
|
|
4766
|
+
case `json`: F.safeParse(e.default).success || t.addIssue({
|
|
4721
4767
|
code: `custom`,
|
|
4722
4768
|
path: [`default`],
|
|
4723
4769
|
message: `json flag default must be JSON-serializable`
|
|
4724
4770
|
});
|
|
4725
4771
|
}
|
|
4726
4772
|
}
|
|
4727
|
-
const
|
|
4773
|
+
const L = z.record(o, z.discriminatedUnion(`type`, [
|
|
4774
|
+
z.object({
|
|
4775
|
+
type: z.literal(`string`),
|
|
4776
|
+
values: z.tuple([z.string()], z.string()).optional(),
|
|
4777
|
+
required: z.boolean().optional()
|
|
4778
|
+
}),
|
|
4779
|
+
z.object({
|
|
4780
|
+
type: z.literal(`number`),
|
|
4781
|
+
required: z.boolean().optional()
|
|
4782
|
+
}),
|
|
4783
|
+
z.object({
|
|
4784
|
+
type: z.literal(`boolean`),
|
|
4785
|
+
required: z.boolean().optional()
|
|
4786
|
+
})
|
|
4787
|
+
])).superRefine((e, t) => {
|
|
4788
|
+
for (let n of [
|
|
4789
|
+
`userId`,
|
|
4790
|
+
`country`,
|
|
4791
|
+
`region`,
|
|
4792
|
+
`city`,
|
|
4793
|
+
`timezone`
|
|
4794
|
+
]) Object.hasOwn(e, n) && e[n]?.type !== `string` && t.addIssue({
|
|
4795
|
+
code: `custom`,
|
|
4796
|
+
path: [n, `type`],
|
|
4797
|
+
message: `built-in trait "${n}" must be a string`
|
|
4798
|
+
});
|
|
4799
|
+
});
|
|
4800
|
+
const R = z.custom((e) => typeof e == `object` && !!e && !Array.isArray(e), { message: `trait definitions must be an object` }).superRefine((e, t) => {
|
|
4801
|
+
Object.hasOwn(e, `__proto__`) && t.addIssue({
|
|
4802
|
+
code: `custom`,
|
|
4803
|
+
path: [`__proto__`],
|
|
4804
|
+
message: `trait key "__proto__" is reserved`
|
|
4805
|
+
});
|
|
4806
|
+
}).pipe(L);
|
|
4807
|
+
function z$1(e, t) {
|
|
4808
|
+
if (!e.traits || !e.targeting) return;
|
|
4809
|
+
let n = {
|
|
4810
|
+
userId: { type: `string` },
|
|
4811
|
+
country: { type: `string` },
|
|
4812
|
+
region: { type: `string` },
|
|
4813
|
+
city: { type: `string` },
|
|
4814
|
+
timezone: { type: `string` },
|
|
4815
|
+
...e.traits
|
|
4816
|
+
}, r = (e) => t.addIssue({
|
|
4817
|
+
code: `custom`,
|
|
4818
|
+
path: [`targeting`],
|
|
4819
|
+
message: e
|
|
4820
|
+
}), i = (e) => {
|
|
4821
|
+
e && !Object.hasOwn(n, e) && r(`undeclared bucketing trait "${e}"`);
|
|
4822
|
+
}, a = (e) => {
|
|
4823
|
+
if (e.kind === `group`) {
|
|
4824
|
+
e.conditions.forEach(a);
|
|
4825
|
+
return;
|
|
4826
|
+
}
|
|
4827
|
+
if (e.kind === `percentage`) {
|
|
4828
|
+
i(e.attribute);
|
|
4829
|
+
return;
|
|
4830
|
+
}
|
|
4831
|
+
if (e.kind !== `attribute`) return;
|
|
4832
|
+
if (!Object.hasOwn(n, e.attribute)) {
|
|
4833
|
+
r(`undeclared trait "${e.attribute}"`);
|
|
4834
|
+
return;
|
|
4835
|
+
}
|
|
4836
|
+
let t = n[e.attribute];
|
|
4837
|
+
if (e.operator !== `exists` && e.operator !== `not_exists` && ([
|
|
4838
|
+
`contains`,
|
|
4839
|
+
`startsWith`,
|
|
4840
|
+
`endsWith`
|
|
4841
|
+
].includes(e.operator) && t.type !== `string` && r(`operator ${e.operator} requires a string trait`), [
|
|
4842
|
+
`gt`,
|
|
4843
|
+
`gte`,
|
|
4844
|
+
`lt`,
|
|
4845
|
+
`lte`
|
|
4846
|
+
].includes(e.operator) && t.type !== `number` && t.type !== `string` && r(`operator ${e.operator} requires a number or string trait`), `value` in e)) for (let n of Array.isArray(e.value) ? e.value : [e.value]) (typeof n !== t.type || t.type === `string` && [
|
|
4847
|
+
`eq`,
|
|
4848
|
+
`neq`,
|
|
4849
|
+
`in`,
|
|
4850
|
+
`not_in`
|
|
4851
|
+
].includes(e.operator) && t.values && !t.values.includes(String(n))) && r(`invalid value for trait "${e.attribute}"`);
|
|
4852
|
+
}, o = (e) => {
|
|
4853
|
+
e.kind === `weighted` && i(e.attribute);
|
|
4854
|
+
};
|
|
4855
|
+
o(e.targeting.fallthrough), e.targeting.rules.forEach((e) => {
|
|
4856
|
+
e.conditions.forEach(a), o(e.serve);
|
|
4857
|
+
});
|
|
4858
|
+
}
|
|
4859
|
+
const B = z.object({
|
|
4860
|
+
enabled: z.boolean(),
|
|
4861
|
+
rules: z.array(y).max(500),
|
|
4862
|
+
fallthrough: u
|
|
4863
|
+
}).strict().superRefine((e, t) => {
|
|
4864
|
+
let n = /* @__PURE__ */ new Set();
|
|
4865
|
+
e.rules.forEach((e, r) => {
|
|
4866
|
+
n.has(e.id) && t.addIssue({
|
|
4867
|
+
code: `custom`,
|
|
4868
|
+
path: [
|
|
4869
|
+
`rules`,
|
|
4870
|
+
r,
|
|
4871
|
+
`id`
|
|
4872
|
+
],
|
|
4873
|
+
message: `duplicate rule id`
|
|
4874
|
+
}), n.add(e.id);
|
|
4875
|
+
});
|
|
4876
|
+
});
|
|
4877
|
+
function V(e, t) {
|
|
4878
|
+
if (!e.targeting) return;
|
|
4879
|
+
let n = (n, r) => {
|
|
4880
|
+
n.kind === `weighted` && !Number.isFinite(n.variations.reduce((e, t) => e + t.weight, 0)) && t.addIssue({
|
|
4881
|
+
code: `custom`,
|
|
4882
|
+
path: r,
|
|
4883
|
+
message: `total weight must be finite`
|
|
4884
|
+
});
|
|
4885
|
+
let i = n.kind === `weighted` ? n.variations.map((e) => e.serve) : [n];
|
|
4886
|
+
for (let n of i) n.kind !== `disabled` && (n.kind !== e.type || n.kind === `variant` && !e.variants?.includes(n.value) || n.kind === `json` && !P(n.value)) && t.addIssue({
|
|
4887
|
+
code: `custom`,
|
|
4888
|
+
path: r,
|
|
4889
|
+
message: `serve must match the flag type and declared variants and contain JSON values`
|
|
4890
|
+
});
|
|
4891
|
+
};
|
|
4892
|
+
n(e.targeting.fallthrough, [`targeting`, `fallthrough`]), e.targeting.rules.forEach((e, t) => n(e.serve, [
|
|
4893
|
+
`targeting`,
|
|
4894
|
+
`rules`,
|
|
4895
|
+
t,
|
|
4896
|
+
`serve`
|
|
4897
|
+
]));
|
|
4898
|
+
}
|
|
4899
|
+
const H = z.object({
|
|
4900
|
+
type: t,
|
|
4901
|
+
variants: z.array(z.string()).optional(),
|
|
4902
|
+
traits: R.optional(),
|
|
4903
|
+
targeting: B.optional()
|
|
4904
|
+
}).superRefine(V).superRefine(z$1);
|
|
4905
|
+
const U = z.object({
|
|
4728
4906
|
key: o,
|
|
4729
4907
|
type: t,
|
|
4730
4908
|
default: z.unknown(),
|
|
4731
4909
|
description: z.string().optional(),
|
|
4732
4910
|
tags: z.array(z.string()).default([]),
|
|
4733
|
-
lifecycle:
|
|
4911
|
+
lifecycle: M.default(`active`),
|
|
4734
4912
|
variants: z.array(z.string()).optional(),
|
|
4735
|
-
disabled: z.boolean().optional()
|
|
4913
|
+
disabled: z.boolean().optional(),
|
|
4914
|
+
targeting: B.optional(),
|
|
4915
|
+
traits: R.optional()
|
|
4736
4916
|
});
|
|
4737
|
-
const
|
|
4738
|
-
const
|
|
4917
|
+
const W = U.superRefine(I).superRefine(V).superRefine(z$1);
|
|
4918
|
+
const G = U.extend({
|
|
4739
4919
|
version: z.number().int().positive(),
|
|
4740
4920
|
environmentVersion: z.number().int().positive().optional(),
|
|
4741
4921
|
managedBy: n
|
|
4742
|
-
}).superRefine(
|
|
4743
|
-
const
|
|
4922
|
+
}).superRefine(I).superRefine(V).superRefine(z$1);
|
|
4923
|
+
const K = z.object({
|
|
4744
4924
|
version: z.number().int().positive(),
|
|
4745
4925
|
environmentVersion: z.number().int().positive().optional()
|
|
4746
4926
|
});
|
|
4747
|
-
const
|
|
4927
|
+
const q = z.object({
|
|
4748
4928
|
projectId: z.string().min(1),
|
|
4749
4929
|
environmentId: z.string().min(1)
|
|
4750
4930
|
});
|
|
4751
|
-
const
|
|
4931
|
+
const J = z.object({
|
|
4752
4932
|
projectId: z.string(),
|
|
4753
4933
|
environmentId: z.string(),
|
|
4754
|
-
flags: z.array(
|
|
4934
|
+
flags: z.array(G)
|
|
4755
4935
|
});
|
|
4756
|
-
function
|
|
4936
|
+
function Y(e, t) {
|
|
4757
4937
|
let n = /* @__PURE__ */ new Set();
|
|
4758
4938
|
for (let [r, i] of e.entries()) n.has(i.key) && t.addIssue({
|
|
4759
4939
|
code: `custom`,
|
|
@@ -4765,12 +4945,12 @@ function W(e, t) {
|
|
|
4765
4945
|
message: `duplicate flag key "${i.key}"`
|
|
4766
4946
|
}), n.add(i.key);
|
|
4767
4947
|
}
|
|
4768
|
-
const
|
|
4948
|
+
const X = z.object({
|
|
4769
4949
|
projectId: z.string().min(1),
|
|
4770
4950
|
environmentId: z.string().min(1),
|
|
4771
|
-
flags: z.array(
|
|
4772
|
-
}).superRefine((e, t) =>
|
|
4773
|
-
const
|
|
4951
|
+
flags: z.array(W).max(500)
|
|
4952
|
+
}).superRefine((e, t) => Y(e.flags, t));
|
|
4953
|
+
const Z = z.object({
|
|
4774
4954
|
key: z.string(),
|
|
4775
4955
|
op: z.enum([
|
|
4776
4956
|
`add`,
|
|
@@ -4778,32 +4958,32 @@ const K = z.object({
|
|
|
4778
4958
|
`remove`,
|
|
4779
4959
|
`unlinked`
|
|
4780
4960
|
]),
|
|
4781
|
-
before:
|
|
4782
|
-
after:
|
|
4961
|
+
before: G.optional(),
|
|
4962
|
+
after: W.optional(),
|
|
4783
4963
|
message: z.string().optional()
|
|
4784
4964
|
});
|
|
4785
|
-
const
|
|
4965
|
+
const Q = z.object({
|
|
4786
4966
|
projectId: z.string(),
|
|
4787
4967
|
environmentId: z.string(),
|
|
4788
|
-
changes: z.array(
|
|
4789
|
-
remoteOnly: z.array(
|
|
4968
|
+
changes: z.array(Z),
|
|
4969
|
+
remoteOnly: z.array(G).default([])
|
|
4790
4970
|
});
|
|
4791
|
-
const
|
|
4971
|
+
const $ = z.object({
|
|
4792
4972
|
projectId: z.string().min(1),
|
|
4793
4973
|
environmentId: z.string().min(1),
|
|
4794
|
-
flags: z.array(
|
|
4974
|
+
flags: z.array(W).max(500),
|
|
4795
4975
|
apply: z.boolean().default(!1),
|
|
4796
4976
|
prune: z.boolean().default(!1),
|
|
4797
4977
|
force: z.boolean().default(!1),
|
|
4798
4978
|
adopt: z.boolean().default(!1),
|
|
4799
|
-
expectedVersions: z.record(z.string(),
|
|
4800
|
-
}).superRefine((e, t) =>
|
|
4801
|
-
const
|
|
4979
|
+
expectedVersions: z.record(z.string(), K).optional()
|
|
4980
|
+
}).superRefine((e, t) => Y(e.flags, t));
|
|
4981
|
+
const ee = z.object({
|
|
4802
4982
|
projectId: z.string(),
|
|
4803
4983
|
environmentId: z.string(),
|
|
4804
4984
|
applied: z.boolean(),
|
|
4805
|
-
changes: z.array(
|
|
4806
|
-
remoteOnly: z.array(
|
|
4985
|
+
changes: z.array(Z),
|
|
4986
|
+
remoteOnly: z.array(G).default([]),
|
|
4807
4987
|
forced: z.boolean().default(!1),
|
|
4808
4988
|
adopted: z.boolean().default(!1),
|
|
4809
4989
|
approvalRequests: z.array(z.string()).default([]),
|
|
@@ -4970,10 +5150,32 @@ function goValue(value) {
|
|
|
4970
5150
|
if (typeof value === "object") return `map[string]any{${Object.entries(value).map(([key, entry]) => `${goString(key)}: ${goValue(entry)}`).join(", ")}}`;
|
|
4971
5151
|
return JSON.stringify(value);
|
|
4972
5152
|
}
|
|
5153
|
+
function goCondition(c) {
|
|
5154
|
+
const fields = [`Kind: ${goString(c.kind)}`];
|
|
5155
|
+
for (const [key, value] of Object.entries(c)) {
|
|
5156
|
+
if (key === "kind") continue;
|
|
5157
|
+
const name = key === "segmentId" ? "SegmentID" : key[0].toUpperCase() + key.slice(1);
|
|
5158
|
+
fields.push(`${name}: ${key === "conditions" ? `[]config.Condition{${value.map(goCondition).join(", ")}}` : goValue(value)}`);
|
|
5159
|
+
}
|
|
5160
|
+
return `{${fields.join(", ")}}`;
|
|
5161
|
+
}
|
|
5162
|
+
function goServe(s) {
|
|
5163
|
+
const fields = [`Kind: ${goString(s.kind)}`];
|
|
5164
|
+
for (const [key, value] of Object.entries(s)) {
|
|
5165
|
+
if (key === "kind") continue;
|
|
5166
|
+
fields.push(`${key[0].toUpperCase() + key.slice(1)}: ${key === "variations" ? `[]config.WeightedVariation{${value.map((v) => `{Weight: ${goNumber(v.weight)}, Serve: config.Serve${goServe(v.serve)}}`).join(", ")}}` : goValue(value)}`);
|
|
5167
|
+
}
|
|
5168
|
+
return `{${fields.join(", ")}}`;
|
|
5169
|
+
}
|
|
5170
|
+
function goTargeting(t) {
|
|
5171
|
+
return `&config.Targeting{Enabled: ${t.enabled}, Rules: []config.Rule{${t.rules.map((r) => `{ID: ${goString(r.id)}, ${r.description !== void 0 ? `Description: ${goString(r.description)}, ` : ""}Conditions: []config.Condition{${r.conditions.map(goCondition).join(", ")}}, Serve: config.Serve${goServe(r.serve)}}`).join(", ")}}, Fallthrough: config.Serve${goServe(t.fallthrough)}}`;
|
|
5172
|
+
}
|
|
4973
5173
|
/** Emits gofmt-clean Go: one block per flag, field values aligned as gofmt does. */
|
|
4974
5174
|
function generateGoConfigSource(flags, packageName = "main") {
|
|
4975
5175
|
const entries = flags.map((flag) => {
|
|
4976
5176
|
const fields = [["Type", goString(flag.type)], ["Default", goValue(flag.default)]];
|
|
5177
|
+
if (flag.traits !== void 0) fields.push(["Traits", `map[string]config.TraitDefinition{${Object.entries(flag.traits).map(([key, t]) => `${goString(key)}: {Type: ${goString(t.type)}${"values" in t && t.values ? `, Values: []string{${t.values.map(goString).join(", ")}}` : ""}${t.required ? ", Required: true" : ""}}`).join(", ")}}`]);
|
|
5178
|
+
if (flag.targeting) fields.push(["Targeting", goTargeting(flag.targeting)]);
|
|
4977
5179
|
if (flag.variants) fields.push(["Variants", `[]string{${flag.variants.map((v) => goString(v)).join(", ")}}`]);
|
|
4978
5180
|
if (flag.description !== void 0) fields.push(["Description", goString(flag.description)]);
|
|
4979
5181
|
if (flag.tags.length) fields.push(["Tags", `[]string{${flag.tags.map((v) => goString(v)).join(", ")}}`]);
|
|
@@ -4994,7 +5196,7 @@ var Config = config.ShipdConfig${entries.length ? `{\n${entries.join("\n")}\n}`
|
|
|
4994
5196
|
|
|
4995
5197
|
//#endregion
|
|
4996
5198
|
//#region src/lib/local-config.ts
|
|
4997
|
-
const localFlagsArraySchema = z.array(
|
|
5199
|
+
const localFlagsArraySchema = z.array(W).superRefine((flags, ctx) => {
|
|
4998
5200
|
const seen = /* @__PURE__ */ new Set();
|
|
4999
5201
|
for (const [index, flag] of flags.entries()) {
|
|
5000
5202
|
if (seen.has(flag.key)) ctx.addIssue({
|
|
@@ -5035,7 +5237,9 @@ async function loadLocalFlags(configFile) {
|
|
|
5035
5237
|
tags: flag.tags ?? [],
|
|
5036
5238
|
lifecycle: flag.lifecycle ?? (flag.deprecated === true ? "deprecated" : "active"),
|
|
5037
5239
|
variants: flag.variants,
|
|
5038
|
-
disabled: flag.disabled
|
|
5240
|
+
disabled: flag.disabled,
|
|
5241
|
+
targeting: flag.targeting,
|
|
5242
|
+
traits: flag.traits
|
|
5039
5243
|
}));
|
|
5040
5244
|
const parsed = localFlagsArraySchema.safeParse(candidates);
|
|
5041
5245
|
if (!parsed.success) {
|
|
@@ -5050,7 +5254,9 @@ async function loadLocalFlags(configFile) {
|
|
|
5050
5254
|
tags: flag.tags,
|
|
5051
5255
|
lifecycle: flag.lifecycle,
|
|
5052
5256
|
variants: flag.variants,
|
|
5053
|
-
disabled: flag.disabled
|
|
5257
|
+
disabled: flag.disabled,
|
|
5258
|
+
targeting: flag.targeting,
|
|
5259
|
+
traits: flag.traits
|
|
5054
5260
|
}));
|
|
5055
5261
|
}
|
|
5056
5262
|
function serializeValue(value) {
|
|
@@ -5069,6 +5275,8 @@ ${flags.map((flag) => {
|
|
|
5069
5275
|
if (flag.type === "variant" && flag.variants) lines.push(` variants: ${JSON.stringify(flag.variants)} as const,`, ` default: ${JSON.stringify(flag.default)},`);
|
|
5070
5276
|
else if (flag.type === "json") lines.push(` default: ${serializeValue(flag.default)},`);
|
|
5071
5277
|
else lines.push(` default: ${JSON.stringify(flag.default)},`);
|
|
5278
|
+
if (flag.traits !== void 0) lines.push(` traits: ${serializeValue(flag.traits)},`);
|
|
5279
|
+
if (flag.targeting !== void 0) lines.push(` targeting: ${serializeValue(flag.targeting)},`);
|
|
5072
5280
|
if (flag.description !== void 0) lines.push(` description: ${JSON.stringify(flag.description)},`);
|
|
5073
5281
|
if (flag.tags.length > 0) lines.push(` tags: ${JSON.stringify(flag.tags)},`);
|
|
5074
5282
|
if (flag.lifecycle === "deprecated") lines.push(` deprecated: true,`);
|
|
@@ -5085,6 +5293,7 @@ function generateTypesSource(flags) {
|
|
|
5085
5293
|
const variants = flag.variants && flag.variants.length > 0 ? flag.variants.map((v) => JSON.stringify(v)).join(" | ") : "string";
|
|
5086
5294
|
lines.push(` variants: ${variants};`);
|
|
5087
5295
|
}
|
|
5296
|
+
if (flag.traits !== void 0) lines.push(` traits: ${serializeTypeLiteral(flag.traits)};`);
|
|
5088
5297
|
lines.push(` default: ${serializeTypeLiteral(flag.default)};`);
|
|
5089
5298
|
lines.push(` };`);
|
|
5090
5299
|
return lines.join("\n");
|
|
@@ -5097,6 +5306,8 @@ ${flags.length === 0 ? " // No flags defined in shipd.config.ts\n" : `${entries
|
|
|
5097
5306
|
|
|
5098
5307
|
export type FlagKey = keyof FlagDefinitions;
|
|
5099
5308
|
|
|
5309
|
+
export type FlagTraits<K extends FlagKey> = import("shipdit/config").TraitsFor<FlagDefinitions[K]>;
|
|
5310
|
+
|
|
5100
5311
|
export type BooleanFlagKey = {
|
|
5101
5312
|
[K in FlagKey]: FlagDefinitions[K]["type"] extends "boolean" ? K : never;
|
|
5102
5313
|
}[FlagKey];
|
|
@@ -5135,10 +5346,12 @@ const DEFINITION_FIELDS = [
|
|
|
5135
5346
|
"type",
|
|
5136
5347
|
"default",
|
|
5137
5348
|
"disabled",
|
|
5349
|
+
"targeting",
|
|
5138
5350
|
"description",
|
|
5139
5351
|
"tags",
|
|
5140
5352
|
"lifecycle",
|
|
5141
|
-
"variants"
|
|
5353
|
+
"variants",
|
|
5354
|
+
"traits"
|
|
5142
5355
|
];
|
|
5143
5356
|
function formatValue(value) {
|
|
5144
5357
|
if (value === void 0) return "undefined";
|
|
@@ -5147,9 +5360,11 @@ function formatValue(value) {
|
|
|
5147
5360
|
function fieldChanges(before, after) {
|
|
5148
5361
|
const fields = {};
|
|
5149
5362
|
for (const field of DEFINITION_FIELDS) {
|
|
5363
|
+
if (field === "traits" && after.traits === void 0) continue;
|
|
5364
|
+
if (field === "targeting" && after.targeting === void 0) continue;
|
|
5150
5365
|
const from = before[field];
|
|
5151
5366
|
const to = after[field];
|
|
5152
|
-
if (
|
|
5367
|
+
if (!isDeepStrictEqual(from ?? null, to ?? null)) fields[field] = {
|
|
5153
5368
|
from,
|
|
5154
5369
|
to
|
|
5155
5370
|
};
|
|
@@ -5161,7 +5376,8 @@ const DEFINITION_ONLY_FIELDS = [
|
|
|
5161
5376
|
"description",
|
|
5162
5377
|
"tags",
|
|
5163
5378
|
"lifecycle",
|
|
5164
|
-
"variants"
|
|
5379
|
+
"variants",
|
|
5380
|
+
"traits"
|
|
5165
5381
|
];
|
|
5166
5382
|
function planHasDefinitionChanges(plan) {
|
|
5167
5383
|
if (plan.creates.length > 0 || plan.archives.length > 0) return true;
|
|
@@ -5390,6 +5606,70 @@ function registerProjectsCommands(program) {
|
|
|
5390
5606
|
});
|
|
5391
5607
|
}
|
|
5392
5608
|
|
|
5609
|
+
//#endregion
|
|
5610
|
+
//#region src/lib/sync-state.ts
|
|
5611
|
+
const stateSchema = z.object({
|
|
5612
|
+
version: z.literal(1),
|
|
5613
|
+
flags: z.record(o, B)
|
|
5614
|
+
}).strict();
|
|
5615
|
+
function stateFile(runtime, projectId, environmentId) {
|
|
5616
|
+
const identity = JSON.stringify([
|
|
5617
|
+
runtime.apiUrl,
|
|
5618
|
+
projectId,
|
|
5619
|
+
environmentId,
|
|
5620
|
+
path.resolve(runtime.configFile)
|
|
5621
|
+
]);
|
|
5622
|
+
const key = createHash("sha256").update(identity).digest("hex");
|
|
5623
|
+
return path.join(runtime.projectDir ?? path.dirname(runtime.configFile), ".shipd", "sync", `${key}.json`);
|
|
5624
|
+
}
|
|
5625
|
+
function canonical(value) {
|
|
5626
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
5627
|
+
if (value !== null && typeof value === "object") return `{${Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`;
|
|
5628
|
+
return JSON.stringify(value) ?? "null";
|
|
5629
|
+
}
|
|
5630
|
+
function readSyncState(runtime, projectId, environmentId) {
|
|
5631
|
+
const file = stateFile(runtime, projectId, environmentId);
|
|
5632
|
+
if (!fs.existsSync(file)) return;
|
|
5633
|
+
try {
|
|
5634
|
+
const raw = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
5635
|
+
if (raw?.flags && Object.hasOwn(raw.flags, "__proto__")) throw new Error("reserved flag key");
|
|
5636
|
+
return stateSchema.parse(raw);
|
|
5637
|
+
} catch {
|
|
5638
|
+
throw new CliError("validation_error", `Invalid sync baseline: ${file}`);
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
function writeSyncState(runtime, projectId, environmentId, flags) {
|
|
5642
|
+
const file = stateFile(runtime, projectId, environmentId);
|
|
5643
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
5644
|
+
const state = {
|
|
5645
|
+
version: 1,
|
|
5646
|
+
flags: Object.fromEntries(flags.filter((f) => f.targeting !== void 0).map((f) => [f.key, f.targeting]))
|
|
5647
|
+
};
|
|
5648
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
5649
|
+
try {
|
|
5650
|
+
fs.writeFileSync(temp, JSON.stringify(state, null, 2) + "\n", { mode: 384 });
|
|
5651
|
+
fs.renameSync(temp, file);
|
|
5652
|
+
} finally {
|
|
5653
|
+
fs.rmSync(temp, { force: true });
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
function assertNoRemoteTargetingChanges(state, changes) {
|
|
5657
|
+
if (!state) return;
|
|
5658
|
+
for (const change of changes) {
|
|
5659
|
+
if (change.after?.targeting === void 0) continue;
|
|
5660
|
+
const base = Object.hasOwn(state.flags, change.key) ? state.flags[change.key] : void 0;
|
|
5661
|
+
if (base && canonical(base) !== canonical(change.before?.targeting) && canonical(change.after.targeting) !== canonical(change.before?.targeting)) throw new CliError("conflict", `Flag "${change.key}" targeting changed in the dashboard since the last sync. Pull and reconcile, or push --force to overwrite.`, { exitCode: 3 });
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
function assertPullPreservesLocalTargeting(state, local, remote) {
|
|
5665
|
+
if (!state) return;
|
|
5666
|
+
const byKey = new Map(remote.map((f) => [f.key, f]));
|
|
5667
|
+
for (const flag of local) {
|
|
5668
|
+
const base = Object.hasOwn(state.flags, flag.key) ? state.flags[flag.key] : void 0;
|
|
5669
|
+
if (flag.targeting !== void 0 && canonical(flag.targeting) !== canonical(base) && canonical(flag.targeting) !== canonical(byKey.get(flag.key)?.targeting)) throw new CliError("conflict", `Pull would overwrite local targeting changes for "${flag.key}". Save your edits separately and reconcile them, or pull --force.`, { exitCode: 3 });
|
|
5670
|
+
}
|
|
5671
|
+
}
|
|
5672
|
+
|
|
5393
5673
|
//#endregion
|
|
5394
5674
|
//#region src/lib/go-typegen.ts
|
|
5395
5675
|
const GO_KEYWORDS = new Set("break default func interface select case defer go map struct chan else goto package switch const fallthrough if range type continue for import return var".split(" "));
|
|
@@ -5410,6 +5690,29 @@ function generateGoTypesSource(flags, packageName = "flags") {
|
|
|
5410
5690
|
const name = claim(goName(flag.key), flag.key);
|
|
5411
5691
|
const keyName = claim(`${name}Key`, flag.key);
|
|
5412
5692
|
const lines = [`const ${keyName} = ${goString(flag.key)}`];
|
|
5693
|
+
if (flag.traits !== void 0) {
|
|
5694
|
+
const traitsName = claim(`${name}Traits`, flag.key);
|
|
5695
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5696
|
+
const fields = [];
|
|
5697
|
+
const assignments = [];
|
|
5698
|
+
for (const [key, trait] of Object.entries(flag.traits)) {
|
|
5699
|
+
const field = goName(key);
|
|
5700
|
+
if (field === "Context" || seen.has(field)) throw new CliError("validation_error", `Go trait identifier ${field} collides for flag ${flag.key}`);
|
|
5701
|
+
seen.add(field);
|
|
5702
|
+
let type = trait.type === "string" ? "string" : trait.type === "number" ? "float64" : "bool";
|
|
5703
|
+
if (trait.type === "string" && trait.values) {
|
|
5704
|
+
type = claim(`${name}${field}Trait`, flag.key);
|
|
5705
|
+
lines.push(`type ${type} string`);
|
|
5706
|
+
for (const value of trait.values) lines.push(`const ${claim(`${type}${goName(value)}`, flag.key)} ${type} = ${goString(value)}`);
|
|
5707
|
+
}
|
|
5708
|
+
fields.push(`\t${field} *${type}`);
|
|
5709
|
+
const scalar = trait.type === "string" && trait.values ? `string(*t.${field})` : `*t.${field}`;
|
|
5710
|
+
if (trait.required) assignments.push(`\tif t.${field} == nil { return shipd.EvaluationContext{}, errors.New(${goString(`missing required trait ${key} for flag ${flag.key}`)}) }`);
|
|
5711
|
+
assignments.push(`\tif t.${field} != nil { attributes[${goString(key)}] = ${scalar} }`);
|
|
5712
|
+
}
|
|
5713
|
+
lines.push(`// ${traitsName} uses pointers to distinguish missing inputs from explicit zero values.\ntype ${traitsName} struct {\n${fields.join("\n")}\n}`);
|
|
5714
|
+
lines.push(`func (t ${traitsName}) Context(userID string) (shipd.EvaluationContext, error) {\n\tattributes := map[string]any{}\n${assignments.join("\n")}\n\treturn shipd.EvaluationContext{UserID: userID, Attributes: attributes}, nil\n}`);
|
|
5715
|
+
}
|
|
5413
5716
|
let returnType;
|
|
5414
5717
|
let expression;
|
|
5415
5718
|
switch (flag.type) {
|
|
@@ -5443,7 +5746,7 @@ package ${packageName}
|
|
|
5443
5746
|
|
|
5444
5747
|
import (
|
|
5445
5748
|
\t"encoding/json"
|
|
5446
|
-
${flags.length ? " shipd \"github.com/alasti-company/useshipd.com/sdks/go\"\n" : ""})
|
|
5749
|
+
${flags.some((f) => Object.values(f.traits ?? {}).some((t) => t.required)) ? " \"errors\"\n" : ""}${flags.length ? " shipd \"github.com/alasti-company/useshipd.com/sdks/go\"\n" : ""})
|
|
5447
5750
|
|
|
5448
5751
|
// Defaults returns a fresh map of the config's defaults for shipd.Options.
|
|
5449
5752
|
func Defaults() map[string]any {
|
|
@@ -5483,7 +5786,7 @@ function writeTypegen(prepared) {
|
|
|
5483
5786
|
//#endregion
|
|
5484
5787
|
//#region src/commands/pull.ts
|
|
5485
5788
|
function registerPullCommand(program) {
|
|
5486
|
-
program.command("pull").description("Regenerate the flag config from the server and run typegen").action(async (
|
|
5789
|
+
program.command("pull").description("Regenerate the flag config from the server and run typegen").option("--force", "Overwrite unsynced local targeting", false).action(async (opts, command) => {
|
|
5487
5790
|
const runtime = getRuntime(command);
|
|
5488
5791
|
const client = await createCliApiClient(runtime);
|
|
5489
5792
|
const { projectId, environmentId } = await resolveIds(client, runtime);
|
|
@@ -5498,8 +5801,12 @@ function registerPullCommand(program) {
|
|
|
5498
5801
|
tags: flag.tags,
|
|
5499
5802
|
lifecycle: flag.lifecycle,
|
|
5500
5803
|
variants: flag.variants,
|
|
5501
|
-
disabled: flag.disabled
|
|
5804
|
+
disabled: flag.disabled,
|
|
5805
|
+
targeting: flag.targeting,
|
|
5806
|
+
traits: flag.traits
|
|
5502
5807
|
}));
|
|
5808
|
+
const baseline = !opts.force ? readSyncState(runtime, projectId, environmentId) : void 0;
|
|
5809
|
+
if (baseline && fs.existsSync(runtime.configFile)) assertPullPreservesLocalTargeting(baseline, await loadLocalFlags(runtime.configFile), localFlags);
|
|
5503
5810
|
const packageName = path.extname(runtime.configFile) === ".go" && fs.existsSync(runtime.configFile) ? goPackageClause(fs.readFileSync(runtime.configFile, "utf8")).name : "main";
|
|
5504
5811
|
const source = path.extname(runtime.configFile) === ".json" ? generateJSONConfigSource(localFlags) : path.extname(runtime.configFile) === ".go" ? generateGoConfigSource(localFlags, packageName) : generateShipdConfigSource(localFlags);
|
|
5505
5812
|
const preparedTypes = prepareTypegen(runtime, localFlags);
|
|
@@ -5507,6 +5814,7 @@ function registerPullCommand(program) {
|
|
|
5507
5814
|
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
5508
5815
|
fs.writeFileSync(outPath, source);
|
|
5509
5816
|
const types = writeTypegen(preparedTypes);
|
|
5817
|
+
writeSyncState(runtime, projectId, environmentId, localFlags);
|
|
5510
5818
|
printResult(runtime, {
|
|
5511
5819
|
written: outPath,
|
|
5512
5820
|
flagCount: localFlags.length,
|
|
@@ -5548,11 +5856,13 @@ function registerPushCommand(program) {
|
|
|
5548
5856
|
force,
|
|
5549
5857
|
adopt
|
|
5550
5858
|
}).catch(mapApiError);
|
|
5859
|
+
if (!force && localFlags.some((f) => f.targeting !== void 0)) assertNoRemoteTargetingChanges(readSyncState(runtime, projectId, environmentId), planned.changes);
|
|
5551
5860
|
const plan = buildSyncPlan(planned.changes);
|
|
5552
5861
|
const remoteOnly = planned.remoteOnly ?? [];
|
|
5553
5862
|
warnRemoteOnly(remoteOnly.map((flag) => flag.key), runtime.json);
|
|
5554
5863
|
if (!runtime.json) console.log(planIsEmpty(plan) ? "Nothing to push." : formatSyncPlan(plan));
|
|
5555
5864
|
if (!planHasDrift(plan)) {
|
|
5865
|
+
if (localFlags.some((f) => f.targeting !== void 0)) writeSyncState(runtime, projectId, environmentId, localFlags);
|
|
5556
5866
|
if (runtime.json) console.log(JSON.stringify({
|
|
5557
5867
|
plan,
|
|
5558
5868
|
remoteOnly
|
|
@@ -5577,6 +5887,7 @@ function registerPushCommand(program) {
|
|
|
5577
5887
|
const types = writeTypegen(preparedTypes);
|
|
5578
5888
|
const approvalRequests = applied.approvalRequests ?? [];
|
|
5579
5889
|
const drafts = applied.drafts ?? [];
|
|
5890
|
+
if (approvalRequests.length === 0 && drafts.length === 0 && localFlags.some((f) => f.targeting !== void 0)) writeSyncState(runtime, projectId, environmentId, localFlags);
|
|
5580
5891
|
printResult(runtime, {
|
|
5581
5892
|
plan: appliedPlan,
|
|
5582
5893
|
remoteOnly,
|