@bash-app/bash-common 30.469.0 → 30.470.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/dist/intros/__tests__/revealClock.test.d.ts +2 -0
- package/dist/intros/__tests__/revealClock.test.d.ts.map +1 -0
- package/dist/intros/__tests__/revealClock.test.js +15 -0
- package/dist/intros/__tests__/revealClock.test.js.map +1 -0
- package/dist/intros/index.d.ts +1 -0
- package/dist/intros/index.d.ts.map +1 -1
- package/dist/intros/index.js +1 -0
- package/dist/intros/index.js.map +1 -1
- package/dist/intros/revealClock.d.ts +6 -0
- package/dist/intros/revealClock.d.ts.map +1 -0
- package/dist/intros/revealClock.js +22 -0
- package/dist/intros/revealClock.js.map +1 -0
- package/package.json +1 -1
- package/prisma/schema.prisma +18 -2
- package/src/intros/__tests__/revealClock.test.ts +18 -0
- package/src/intros/index.ts +1 -0
- package/src/intros/revealClock.ts +24 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revealClock.test.d.ts","sourceRoot":"","sources":["../../../src/intros/__tests__/revealClock.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { introRevealAt } from "../revealClock.js";
|
|
2
|
+
describe("introRevealAt", () => {
|
|
3
|
+
const start = new Date("2026-11-09T20:00:00.000Z");
|
|
4
|
+
it("uses the midpoint when the bash has an end", () => {
|
|
5
|
+
const end = new Date("2026-11-10T00:00:00.000Z");
|
|
6
|
+
expect(introRevealAt(start, end)?.toISOString()).toBe("2026-11-09T22:00:00.000Z");
|
|
7
|
+
});
|
|
8
|
+
it("uses one hour after start when there is no end", () => {
|
|
9
|
+
expect(introRevealAt(start, null)?.toISOString()).toBe("2026-11-09T21:00:00.000Z");
|
|
10
|
+
});
|
|
11
|
+
it("returns null when there is no start", () => {
|
|
12
|
+
expect(introRevealAt(null, null)).toBeNull();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=revealClock.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revealClock.test.js","sourceRoot":"","sources":["../../../src/intros/__tests__/revealClock.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAEnD,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACjD,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/intros/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./intents.js";
|
|
|
6
6
|
export * from "./psychExperiment.js";
|
|
7
7
|
export * from "./reasons.js";
|
|
8
8
|
export * from "./sharedNotes.js";
|
|
9
|
+
export * from "./revealClock.js";
|
|
9
10
|
export * from "./transitions.js";
|
|
10
11
|
export * from "./validation.js";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intros/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intros/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
package/dist/intros/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./intents.js";
|
|
|
6
6
|
export * from "./psychExperiment.js";
|
|
7
7
|
export * from "./reasons.js";
|
|
8
8
|
export * from "./sharedNotes.js";
|
|
9
|
+
export * from "./revealClock.js";
|
|
9
10
|
export * from "./transitions.js";
|
|
10
11
|
export * from "./validation.js";
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/intros/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intros/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intros/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When names become visible. Midpoint of the bash, or one hour after start
|
|
3
|
+
* when the bash has no end. No bash means there is no clock.
|
|
4
|
+
*/
|
|
5
|
+
export declare function introRevealAt(start: Date | string | null | undefined, end: Date | string | null | undefined): Date | null;
|
|
6
|
+
//# sourceMappingURL=revealClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revealClock.d.ts","sourceRoot":"","sources":["../../src/intros/revealClock.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACvC,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC,IAAI,GAAG,IAAI,CAQb"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
2
|
+
function asDate(value) {
|
|
3
|
+
if (!value)
|
|
4
|
+
return null;
|
|
5
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
6
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* When names become visible. Midpoint of the bash, or one hour after start
|
|
10
|
+
* when the bash has no end. No bash means there is no clock.
|
|
11
|
+
*/
|
|
12
|
+
export function introRevealAt(start, end) {
|
|
13
|
+
const startAt = asDate(start);
|
|
14
|
+
if (!startAt)
|
|
15
|
+
return null;
|
|
16
|
+
const endAt = asDate(end);
|
|
17
|
+
if (endAt && endAt.getTime() > startAt.getTime()) {
|
|
18
|
+
return new Date(startAt.getTime() + (endAt.getTime() - startAt.getTime()) / 2);
|
|
19
|
+
}
|
|
20
|
+
return new Date(startAt.getTime() + HOUR_MS);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=revealClock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revealClock.js","sourceRoot":"","sources":["../../src/intros/revealClock.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE/B,SAAS,MAAM,CAAC,KAAuC;IACrD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAuC,EACvC,GAAqC;IAErC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACjD,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
package/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -5073,6 +5073,7 @@ model User {
|
|
|
5073
5073
|
warmIntroOffersAsPartyA WarmIntroOffer[] @relation("WarmIntroOfferPartyA")
|
|
5074
5074
|
warmIntroOffersAsPartyB WarmIntroOffer[] @relation("WarmIntroOfferPartyB")
|
|
5075
5075
|
facilitatedIntroductions Introduction[] @relation("IntroFacilitator")
|
|
5076
|
+
introductionMemberships IntroductionMember[] @relation("IntroductionMemberUser")
|
|
5076
5077
|
links UserLink[]
|
|
5077
5078
|
preferences UserPreferences?
|
|
5078
5079
|
rankings UserRankings?
|
|
@@ -5841,7 +5842,7 @@ model IntrosPair {
|
|
|
5841
5842
|
|
|
5842
5843
|
model Introduction {
|
|
5843
5844
|
id String @id @default(cuid())
|
|
5844
|
-
pairId String
|
|
5845
|
+
pairId String?
|
|
5845
5846
|
bashEventId String?
|
|
5846
5847
|
source IntroductionSource
|
|
5847
5848
|
mode IntroductionMode
|
|
@@ -5871,7 +5872,8 @@ model Introduction {
|
|
|
5871
5872
|
expiresAt DateTime?
|
|
5872
5873
|
version Int @default(0)
|
|
5873
5874
|
createdAt DateTime @default(now())
|
|
5874
|
-
pair IntrosPair
|
|
5875
|
+
pair IntrosPair? @relation(fields: [pairId], references: [id], onDelete: Cascade)
|
|
5876
|
+
members IntroductionMember[]
|
|
5875
5877
|
bashEvent BashEvent? @relation(fields: [bashEventId], references: [id], onDelete: SetNull)
|
|
5876
5878
|
facilitator User? @relation("IntroFacilitator", fields: [facilitatorId], references: [id], onDelete: SetNull)
|
|
5877
5879
|
earlyReveals EarlyRevealRequest[]
|
|
@@ -5882,6 +5884,20 @@ model Introduction {
|
|
|
5882
5884
|
@@index([state, revealAt])
|
|
5883
5885
|
}
|
|
5884
5886
|
|
|
5887
|
+
model IntroductionMember {
|
|
5888
|
+
id String @id @default(cuid())
|
|
5889
|
+
introductionId String
|
|
5890
|
+
userId String
|
|
5891
|
+
interest IntroInterest @default(Pending)
|
|
5892
|
+
interestAt DateTime?
|
|
5893
|
+
saidHiAt DateTime?
|
|
5894
|
+
introduction Introduction @relation(fields: [introductionId], references: [id], onDelete: Cascade)
|
|
5895
|
+
user User @relation("IntroductionMemberUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
5896
|
+
|
|
5897
|
+
@@unique([introductionId, userId])
|
|
5898
|
+
@@index([userId])
|
|
5899
|
+
}
|
|
5900
|
+
|
|
5885
5901
|
model WarmIntroSuggestion {
|
|
5886
5902
|
id String @id @default(cuid())
|
|
5887
5903
|
facilitatorId String
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { introRevealAt } from "../revealClock.js";
|
|
2
|
+
|
|
3
|
+
describe("introRevealAt", () => {
|
|
4
|
+
const start = new Date("2026-11-09T20:00:00.000Z");
|
|
5
|
+
|
|
6
|
+
it("uses the midpoint when the bash has an end", () => {
|
|
7
|
+
const end = new Date("2026-11-10T00:00:00.000Z");
|
|
8
|
+
expect(introRevealAt(start, end)?.toISOString()).toBe("2026-11-09T22:00:00.000Z");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses one hour after start when there is no end", () => {
|
|
12
|
+
expect(introRevealAt(start, null)?.toISOString()).toBe("2026-11-09T21:00:00.000Z");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("returns null when there is no start", () => {
|
|
16
|
+
expect(introRevealAt(null, null)).toBeNull();
|
|
17
|
+
});
|
|
18
|
+
});
|
package/src/intros/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
2
|
+
|
|
3
|
+
function asDate(value: Date | string | null | undefined): Date | null {
|
|
4
|
+
if (!value) return null;
|
|
5
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
6
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* When names become visible. Midpoint of the bash, or one hour after start
|
|
11
|
+
* when the bash has no end. No bash means there is no clock.
|
|
12
|
+
*/
|
|
13
|
+
export function introRevealAt(
|
|
14
|
+
start: Date | string | null | undefined,
|
|
15
|
+
end: Date | string | null | undefined
|
|
16
|
+
): Date | null {
|
|
17
|
+
const startAt = asDate(start);
|
|
18
|
+
if (!startAt) return null;
|
|
19
|
+
const endAt = asDate(end);
|
|
20
|
+
if (endAt && endAt.getTime() > startAt.getTime()) {
|
|
21
|
+
return new Date(startAt.getTime() + (endAt.getTime() - startAt.getTime()) / 2);
|
|
22
|
+
}
|
|
23
|
+
return new Date(startAt.getTime() + HOUR_MS);
|
|
24
|
+
}
|