@shaxpir/duiduidui-models 1.0.0 → 1.1.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/models/{content/ArrayView.d.ts → ArrayView.d.ts} +1 -1
- package/dist/models/{content/ArrayView.js → ArrayView.js} +14 -14
- package/dist/models/BayesianScore.d.ts +9 -0
- package/dist/models/BayesianScore.js +27 -0
- package/dist/models/{markup/ChangeModel.d.ts → ChangeModel.d.ts} +2 -3
- package/dist/models/{markup/ChangeModel.js → ChangeModel.js} +20 -10
- package/dist/models/{content/Content.d.ts → Content.d.ts} +9 -10
- package/dist/models/{content/Content.js → Content.js} +2 -6
- package/dist/models/{content/ContentKind.d.ts → ContentKind.d.ts} +3 -0
- package/dist/models/{content/ContentKind.js → ContentKind.js} +5 -1
- package/dist/models/{content/Device.d.ts → Device.d.ts} +15 -7
- package/dist/models/{content/Device.js → Device.js} +14 -18
- package/dist/models/Hanzi.d.ts +15 -0
- package/dist/models/{content/Manifest.d.ts → Manifest.d.ts} +7 -3
- package/dist/models/{content/Manifest.js → Manifest.js} +12 -8
- package/dist/models/{content/Media.d.ts → Media.d.ts} +2 -3
- package/dist/models/{content/Media.js → Media.js} +4 -5
- package/dist/models/{content/Metric.d.ts → Metric.d.ts} +2 -3
- package/dist/models/{content/Metric.js → Metric.js} +18 -20
- package/dist/models/{content/Model.d.ts → Model.d.ts} +3 -5
- package/dist/models/{content/Model.js → Model.js} +5 -6
- package/dist/models/{markup/Operation.d.ts → Operation.d.ts} +2 -5
- package/dist/models/{markup/Operation.js → Operation.js} +30 -25
- package/dist/models/Phrase.d.ts +39 -0
- package/dist/models/{content/Profile.d.ts → Profile.d.ts} +1 -2
- package/dist/models/{content/Profile.js → Profile.js} +7 -9
- package/dist/models/Progress.d.ts +26 -0
- package/dist/models/Progress.js +39 -0
- package/dist/models/Review.d.ts +14 -0
- package/dist/models/{content/Session.d.ts → Session.d.ts} +7 -15
- package/dist/models/Session.js +103 -0
- package/dist/models/Term.d.ts +36 -0
- package/dist/models/Term.js +82 -0
- package/dist/models/User.d.ts +32 -0
- package/dist/models/User.js +65 -0
- package/dist/models/Workspace.d.ts +37 -0
- package/dist/models/Workspace.js +94 -0
- package/dist/models/index.d.ts +22 -4
- package/dist/models/index.js +22 -4
- package/dist/repo/PermissiveJson1.d.ts +16 -16
- package/dist/repo/PermissiveJson1.js +17 -7
- package/dist/repo/ShareSync.d.ts +6 -6
- package/dist/repo/ShareSync.js +26 -19
- package/dist/repo/index.d.ts +1 -0
- package/dist/repo/index.js +1 -0
- package/dist/util/index.d.ts +0 -14
- package/dist/util/index.js +0 -14
- package/lib/index.ts +5 -0
- package/lib/models/{content/ArrayView.ts → ArrayView.ts} +2 -2
- package/lib/models/BayesianScore.ts +32 -0
- package/lib/models/{markup/ChangeModel.ts → ChangeModel.ts} +3 -4
- package/lib/models/{content/Content.ts → Content.ts} +15 -18
- package/lib/models/{content/ContentKind.ts → ContentKind.ts} +6 -1
- package/lib/models/{content/Device.ts → Device.ts} +26 -22
- package/lib/models/Hanzi.ts +16 -0
- package/lib/models/{content/Manifest.ts → Manifest.ts} +15 -6
- package/lib/models/{content/Media.ts → Media.ts} +3 -4
- package/lib/models/Metric.ts +233 -0
- package/lib/models/{content/Model.ts → Model.ts} +4 -6
- package/lib/models/{markup/Operation.ts → Operation.ts} +6 -16
- package/lib/models/{content/Permissions.ts → Permissions.ts} +0 -2
- package/lib/models/Phrase.ts +53 -0
- package/lib/models/{content/Profile.ts → Profile.ts} +4 -6
- package/lib/models/Progress.ts +66 -0
- package/lib/models/Review.ts +18 -0
- package/lib/models/Session.ts +140 -0
- package/lib/models/Term.ts +139 -0
- package/lib/models/User.ts +97 -0
- package/lib/models/Workspace.ts +129 -0
- package/lib/models/index.ts +24 -0
- package/lib/repo/ShareSync.ts +9 -13
- package/lib/repo/index.ts +6 -0
- package/lib/util/index.ts +4 -0
- package/package.json +4 -15
- package/dist/models/OutboundMessage.d.ts +0 -18
- package/dist/models/OutboundMessage.js +0 -25
- package/dist/models/content/Activity.d.ts +0 -10
- package/dist/models/content/Billing.d.ts +0 -144
- package/dist/models/content/Billing.js +0 -418
- package/dist/models/content/Book.d.ts +0 -77
- package/dist/models/content/Book.js +0 -407
- package/dist/models/content/Category.d.ts +0 -16
- package/dist/models/content/Category.js +0 -20
- package/dist/models/content/Checkpointable.d.ts +0 -21
- package/dist/models/content/Checkpointable.js +0 -156
- package/dist/models/content/Comment.d.ts +0 -19
- package/dist/models/content/Comment.js +0 -53
- package/dist/models/content/ConceptArt.d.ts +0 -31
- package/dist/models/content/ConceptArt.js +0 -84
- package/dist/models/content/Context.d.ts +0 -28
- package/dist/models/content/Context.js +0 -162
- package/dist/models/content/DevEnv.d.ts +0 -5
- package/dist/models/content/DevEnv.js +0 -9
- package/dist/models/content/Dictionary.d.ts +0 -31
- package/dist/models/content/Dictionary.js +0 -5
- package/dist/models/content/DictionaryEntry.d.ts +0 -20
- package/dist/models/content/DictionaryEntry.js +0 -2
- package/dist/models/content/ElasticModel.d.ts +0 -149
- package/dist/models/content/ElasticModel.js +0 -179
- package/dist/models/content/Environment.d.ts +0 -61
- package/dist/models/content/Environment.js +0 -124
- package/dist/models/content/ExportOptions.d.ts +0 -64
- package/dist/models/content/ExportOptions.js +0 -213
- package/dist/models/content/Folder.d.ts +0 -16
- package/dist/models/content/Folder.js +0 -33
- package/dist/models/content/Fragment.d.ts +0 -54
- package/dist/models/content/Fragment.js +0 -181
- package/dist/models/content/Hanzi.d.ts +0 -21
- package/dist/models/content/HighlightRule.d.ts +0 -9
- package/dist/models/content/HighlightRule.js +0 -2
- package/dist/models/content/Migration.d.ts +0 -68
- package/dist/models/content/Migration.js +0 -155
- package/dist/models/content/Phrase.d.ts +0 -8
- package/dist/models/content/Placeholder.d.ts +0 -8
- package/dist/models/content/Placeholder.js +0 -36
- package/dist/models/content/RichText.d.ts +0 -58
- package/dist/models/content/RichText.js +0 -79
- package/dist/models/content/Session.js +0 -173
- package/dist/models/content/Speech.d.ts +0 -67
- package/dist/models/content/Speech.js +0 -97
- package/dist/models/content/Stub.d.ts +0 -24
- package/dist/models/content/Stub.js +0 -179
- package/dist/models/content/Time.d.ts +0 -56
- package/dist/models/content/Time.js +0 -295
- package/dist/models/content/User.d.ts +0 -36
- package/dist/models/content/User.js +0 -95
- package/dist/models/content/Workspace.d.ts +0 -71
- package/dist/models/content/Workspace.js +0 -237
- package/dist/models/content/index.d.ts +0 -36
- package/dist/models/content/index.js +0 -53
- package/dist/models/legacy/LegacyBodyFormat.d.ts +0 -9
- package/dist/models/legacy/LegacyBodyFormat.js +0 -2
- package/dist/models/legacy/LegacyComment.d.ts +0 -12
- package/dist/models/legacy/LegacyComment.js +0 -2
- package/dist/models/legacy/LegacyContent.d.ts +0 -53
- package/dist/models/legacy/LegacyContent.js +0 -55
- package/dist/models/legacy/LegacyConversion.d.ts +0 -55
- package/dist/models/legacy/LegacyConversion.js +0 -401
- package/dist/models/legacy/LegacyFragment.d.ts +0 -21
- package/dist/models/legacy/LegacyFragment.js +0 -2
- package/dist/models/legacy/LegacyLocator.d.ts +0 -8
- package/dist/models/legacy/LegacyLocator.js +0 -31
- package/dist/models/legacy/LegacyOutboundMessage.d.ts +0 -16
- package/dist/models/legacy/LegacyOutboundMessage.js +0 -13
- package/dist/models/legacy/LegacyPicture.d.ts +0 -14
- package/dist/models/legacy/LegacyPicture.js +0 -2
- package/dist/models/legacy/LegacyProfile.d.ts +0 -9
- package/dist/models/legacy/LegacyProfile.js +0 -2
- package/dist/models/legacy/LegacySession.d.ts +0 -41
- package/dist/models/legacy/LegacySession.js +0 -35
- package/dist/models/legacy/LegacyStory.d.ts +0 -23
- package/dist/models/legacy/LegacyStory.js +0 -2
- package/dist/models/legacy/LegacyStub.d.ts +0 -15
- package/dist/models/legacy/LegacyStub.js +0 -2
- package/dist/models/legacy/LegacyTransaction.d.ts +0 -14
- package/dist/models/legacy/LegacyTransaction.js +0 -49
- package/dist/models/legacy/LegacyUser.d.ts +0 -28
- package/dist/models/legacy/LegacyUser.js +0 -32
- package/dist/models/legacy/LegacyWorkspace.d.ts +0 -23
- package/dist/models/legacy/LegacyWorkspace.js +0 -6
- package/dist/models/legacy/index.d.ts +0 -15
- package/dist/models/legacy/index.js +0 -32
- package/dist/models/markup/BodyFormat.d.ts +0 -14
- package/dist/models/markup/BodyFormat.js +0 -190
- package/dist/models/markup/DeltaOps.d.ts +0 -5
- package/dist/models/markup/DeltaOps.js +0 -74
- package/dist/models/markup/HtmlMarkup.d.ts +0 -4
- package/dist/models/markup/HtmlMarkup.js +0 -21
- package/dist/models/markup/index.d.ts +0 -6
- package/dist/models/markup/index.js +0 -23
- package/dist/util/Async.d.ts +0 -8
- package/dist/util/Async.js +0 -18
- package/dist/util/Base62.d.ts +0 -6
- package/dist/util/Base62.js +0 -47
- package/dist/util/BinarySearch.d.ts +0 -7
- package/dist/util/BinarySearch.js +0 -46
- package/dist/util/CachingHasher.d.ts +0 -8
- package/dist/util/CachingHasher.js +0 -41
- package/dist/util/Color.d.ts +0 -32
- package/dist/util/Color.js +0 -204
- package/dist/util/Dispatch.d.ts +0 -15
- package/dist/util/Dispatch.js +0 -79
- package/dist/util/EditDistance.d.ts +0 -13
- package/dist/util/EditDistance.js +0 -184
- package/dist/util/NumberFormat.d.ts +0 -14
- package/dist/util/NumberFormat.js +0 -224
- package/dist/util/Struct.d.ts +0 -4
- package/dist/util/Struct.js +0 -15
- package/dist/util/Template.d.ts +0 -16
- package/dist/util/Template.js +0 -128
- package/dist/util/Text.d.ts +0 -45
- package/dist/util/Text.js +0 -243
- package/dist/util/Tuples.d.ts +0 -9
- package/dist/util/Tuples.js +0 -135
- package/dist/util/Validate.d.ts +0 -4
- package/dist/util/Validate.js +0 -11
- package/dist/util/Vocabulary.d.ts +0 -3
- package/dist/util/Vocabulary.js +0 -35
- package/lib/models/content/Billing.ts +0 -558
- package/lib/models/content/DevEnv.ts +0 -5
- package/lib/models/content/DictionaryEntry.ts +0 -22
- package/lib/models/content/Hanzi.ts +0 -25
- package/lib/models/content/Phrase.ts +0 -10
- package/lib/models/content/Time.ts +0 -328
- package/lib/models/content/User.ts +0 -130
- package/lib/models/markup/DeltaOps.ts +0 -71
- package/lib/util/Base62.ts +0 -47
- package/lib/util/CachingHasher.ts +0 -38
- package/lib/util/Dispatch.ts +0 -92
- package/lib/util/NumberFormat.ts +0 -194
- package/lib/util/Struct.ts +0 -14
- package/lib/util/Tuples.ts +0 -131
- /package/dist/models/{content/GeoLocation.d.ts → GeoLocation.d.ts} +0 -0
- /package/dist/models/{content/GeoLocation.js → GeoLocation.js} +0 -0
- /package/dist/models/{content/Hanzi.js → Hanzi.js} +0 -0
- /package/dist/models/{content/Permissions.d.ts → Permissions.d.ts} +0 -0
- /package/dist/models/{content/Permissions.js → Permissions.js} +0 -0
- /package/dist/models/{content/Phrase.js → Phrase.js} +0 -0
- /package/dist/models/{content/Activity.js → Review.js} +0 -0
- /package/dist/{models/markup → repo}/TextEditOps.d.ts +0 -0
- /package/dist/{models/markup → repo}/TextEditOps.js +0 -0
- /package/lib/models/{content/GeoLocation.ts → GeoLocation.ts} +0 -0
- /package/lib/{models/markup → repo}/TextEditOps.ts +0 -0
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
|
-
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import { ShareSync } from '../../repo/ShareSync';
|
|
4
|
-
import { Content, ContentId, ContentMeta } from "./Content";
|
|
5
|
-
import { MultiTime } from "./Time";
|
|
6
|
-
export interface UserPayload {
|
|
7
|
-
email: string;
|
|
8
|
-
phone: string;
|
|
9
|
-
force_password_reset: boolean;
|
|
10
|
-
pass_md5_salt_md5: string;
|
|
11
|
-
salt: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ModernUserBody {
|
|
14
|
-
meta: ContentMeta;
|
|
15
|
-
payload: UserPayload;
|
|
16
|
-
}
|
|
17
|
-
export declare class ModernUser extends Content {
|
|
18
|
-
static readonly MIN_PASSWORD_LENGTH: number;
|
|
19
|
-
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
20
|
-
get payload(): UserPayload;
|
|
21
|
-
static create(userId: ContentId, payload: UserPayload, createdAt?: MultiTime): ModernUser;
|
|
22
|
-
get email(): string;
|
|
23
|
-
setEmail(value: string): void;
|
|
24
|
-
get forcePasswordReset(): boolean;
|
|
25
|
-
setForcePasswordReset(value: boolean): void;
|
|
26
|
-
get passMd5SaltMd5(): string;
|
|
27
|
-
setPassMd5SaltMd5(value: string): void;
|
|
28
|
-
get salt(): string;
|
|
29
|
-
hasValidPassword(password: string): boolean;
|
|
30
|
-
hasValidPassMd5(passMd5: string): boolean;
|
|
31
|
-
static makePassMd5SaltMd5(salt: string, password: string): string;
|
|
32
|
-
static addSaltToPassMd5(salt: string, passMd5: string): string;
|
|
33
|
-
static makePassMd5(password: string): string;
|
|
34
|
-
static isValidPassMd5(passMd5: string, userPayload: UserPayload): boolean;
|
|
35
|
-
static findByEmail(email: string): Promise<ModernUser[]>;
|
|
36
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModernUser = void 0;
|
|
4
|
-
const ShareSync_1 = require("../../repo/ShareSync");
|
|
5
|
-
const CachingHasher_1 = require("../../util/CachingHasher");
|
|
6
|
-
const Operation_1 = require("../markup/Operation");
|
|
7
|
-
const Content_1 = require("./Content");
|
|
8
|
-
const ContentKind_1 = require("./ContentKind");
|
|
9
|
-
const Time_1 = require("./Time");
|
|
10
|
-
class ModernUser extends Content_1.Content {
|
|
11
|
-
constructor(doc, shouldAcquire, shareSync) {
|
|
12
|
-
super(doc, shouldAcquire, shareSync);
|
|
13
|
-
}
|
|
14
|
-
get payload() {
|
|
15
|
-
return this.doc.data.payload;
|
|
16
|
-
}
|
|
17
|
-
static create(userId, payload, createdAt) {
|
|
18
|
-
// User creation always happens in UTC time
|
|
19
|
-
const now = Time_1.MultiClock.utcNow();
|
|
20
|
-
// If the createdAt time is not provided, use the current time
|
|
21
|
-
createdAt ??= now;
|
|
22
|
-
return ShareSync_1.ShareSyncFactory.get().createContent({
|
|
23
|
-
meta: {
|
|
24
|
-
ref: userId,
|
|
25
|
-
is_head: true,
|
|
26
|
-
kind: ContentKind_1.ContentKind.USER,
|
|
27
|
-
id: userId,
|
|
28
|
-
owner: userId,
|
|
29
|
-
created_at: createdAt,
|
|
30
|
-
updated_at: now
|
|
31
|
-
},
|
|
32
|
-
payload: payload
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
get email() {
|
|
36
|
-
return this.payload.email;
|
|
37
|
-
}
|
|
38
|
-
setEmail(value) {
|
|
39
|
-
if (this.email != value) {
|
|
40
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
41
|
-
batch.setPathValue(['payload', 'email'], value);
|
|
42
|
-
batch.commit();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
get forcePasswordReset() {
|
|
46
|
-
return this.payload.force_password_reset;
|
|
47
|
-
}
|
|
48
|
-
setForcePasswordReset(value) {
|
|
49
|
-
if (this.forcePasswordReset != value) {
|
|
50
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
51
|
-
batch.setPathValue(['payload', 'force_password_reset'], value);
|
|
52
|
-
batch.commit();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
get passMd5SaltMd5() {
|
|
56
|
-
return this.payload.pass_md5_salt_md5;
|
|
57
|
-
}
|
|
58
|
-
setPassMd5SaltMd5(value) {
|
|
59
|
-
if (this.passMd5SaltMd5 != value) {
|
|
60
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
61
|
-
batch.setPathValue(['payload', 'pass_md5_salt_md5'], value);
|
|
62
|
-
batch.commit();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
get salt() {
|
|
66
|
-
return this.payload.salt;
|
|
67
|
-
}
|
|
68
|
-
hasValidPassword(password) {
|
|
69
|
-
const passMd5 = ModernUser.makePassMd5(password);
|
|
70
|
-
return this.hasValidPassMd5(passMd5);
|
|
71
|
-
}
|
|
72
|
-
hasValidPassMd5(passMd5) {
|
|
73
|
-
return ModernUser.isValidPassMd5(passMd5, this.payload);
|
|
74
|
-
}
|
|
75
|
-
static makePassMd5SaltMd5(salt, password) {
|
|
76
|
-
const passMd5 = ModernUser.makePassMd5(password);
|
|
77
|
-
return ModernUser.addSaltToPassMd5(salt, passMd5);
|
|
78
|
-
}
|
|
79
|
-
static addSaltToPassMd5(salt, passMd5) {
|
|
80
|
-
return CachingHasher_1.CachingHasher.makeMd5Hash(passMd5 + salt);
|
|
81
|
-
}
|
|
82
|
-
static makePassMd5(password) {
|
|
83
|
-
return CachingHasher_1.CachingHasher.makeMd5Hash(password);
|
|
84
|
-
}
|
|
85
|
-
static isValidPassMd5(passMd5, userPayload) {
|
|
86
|
-
const passMd5SaltMd5 = ModernUser.addSaltToPassMd5(userPayload.salt, passMd5);
|
|
87
|
-
return passMd5SaltMd5 === userPayload.pass_md5_salt_md5;
|
|
88
|
-
}
|
|
89
|
-
static async findByEmail(email) {
|
|
90
|
-
const shareSync = ShareSync_1.ShareSyncFactory.get();
|
|
91
|
-
return shareSync.findAndAcquire(ContentKind_1.ContentKind.USER, { "payload.email": email });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.ModernUser = ModernUser;
|
|
95
|
-
ModernUser.MIN_PASSWORD_LENGTH = 8;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
|
-
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import { ShareSync } from "../../repo/ShareSync";
|
|
4
|
-
import { ArrayView } from './ArrayView';
|
|
5
|
-
import { Book } from "./Book";
|
|
6
|
-
import { ContentBody, ContentId, ContentMeta } from './Content';
|
|
7
|
-
import { Context } from './Context';
|
|
8
|
-
import { Fragment } from "./Fragment";
|
|
9
|
-
import { Session } from "./Session";
|
|
10
|
-
import { Stub } from "./Stub";
|
|
11
|
-
import { CompactDate, CompactDateTime, MultiTime } from './Time';
|
|
12
|
-
export interface JourneyEntry {
|
|
13
|
-
key: string;
|
|
14
|
-
at_utc_time: CompactDateTime;
|
|
15
|
-
}
|
|
16
|
-
export interface WorkspacePayload {
|
|
17
|
-
devices: ContentId[];
|
|
18
|
-
books: Stub[];
|
|
19
|
-
shorts: Stub[];
|
|
20
|
-
articles: Stub[];
|
|
21
|
-
poems: Stub[];
|
|
22
|
-
ideas: Stub[];
|
|
23
|
-
trash: Stub[];
|
|
24
|
-
sessions: MultiTime[];
|
|
25
|
-
journey?: {
|
|
26
|
-
[key: string]: CompactDateTime;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface WorkspaceBody extends ContentBody {
|
|
30
|
-
meta: ContentMeta;
|
|
31
|
-
payload: WorkspacePayload;
|
|
32
|
-
}
|
|
33
|
-
export declare enum WorkspaceStubArrayKey {
|
|
34
|
-
BOOKS = "books",
|
|
35
|
-
SHORTS = "shorts",
|
|
36
|
-
ARTICLES = "articles",
|
|
37
|
-
POEMS = "poems",
|
|
38
|
-
IDEAS = "ideas",
|
|
39
|
-
TRASH = "trash"
|
|
40
|
-
}
|
|
41
|
-
export declare class Workspace extends Context {
|
|
42
|
-
private _articlesView;
|
|
43
|
-
private _booksView;
|
|
44
|
-
private _ideasView;
|
|
45
|
-
private _poemsView;
|
|
46
|
-
private _shortsView;
|
|
47
|
-
private _devicesView;
|
|
48
|
-
private _sessionsView;
|
|
49
|
-
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
50
|
-
get payload(): WorkspacePayload;
|
|
51
|
-
static makeWorkspaceId(userId: ContentId): ContentId;
|
|
52
|
-
static create(userId: ContentId, deviceId: ContentId): Workspace;
|
|
53
|
-
ensureLatestSchema(): Workspace;
|
|
54
|
-
get articles(): ArrayView<Stub>;
|
|
55
|
-
get books(): ArrayView<Stub>;
|
|
56
|
-
get ideas(): ArrayView<Stub>;
|
|
57
|
-
get poems(): ArrayView<Stub>;
|
|
58
|
-
get shorts(): ArrayView<Stub>;
|
|
59
|
-
get sessions(): ArrayView<MultiTime>;
|
|
60
|
-
getStubArrayKeys(): WorkspaceStubArrayKey[];
|
|
61
|
-
getStubArrayView(key: WorkspaceStubArrayKey): ArrayView<Stub>;
|
|
62
|
-
get devices(): ArrayView<ContentId>;
|
|
63
|
-
addBook(book: Book, activeId: ContentId): void;
|
|
64
|
-
addFragment(fragment: Fragment, stubArrayKey: WorkspaceStubArrayKey, activeId: ContentId): void;
|
|
65
|
-
acquireSessionsFromDate(sessionId: ContentId, localDate: CompactDate): Promise<Session[]>;
|
|
66
|
-
isBookFolderId(id: ContentId): boolean;
|
|
67
|
-
hasJourneyDate(journeyKey: string): boolean;
|
|
68
|
-
getJourneyDate(journeyKey: string): CompactDateTime;
|
|
69
|
-
setJourneyDate(journeyKey: string, journeyDate: CompactDateTime): void;
|
|
70
|
-
mergeIncomingContext(incomingWorkspace: WorkspaceBody): boolean;
|
|
71
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Workspace = exports.WorkspaceStubArrayKey = void 0;
|
|
4
|
-
const ShareSync_1 = require("../../repo/ShareSync");
|
|
5
|
-
const CachingHasher_1 = require("../../util/CachingHasher");
|
|
6
|
-
const Operation_1 = require("../markup/Operation");
|
|
7
|
-
const ArrayView_1 = require("./ArrayView");
|
|
8
|
-
const Content_1 = require("./Content");
|
|
9
|
-
const ContentKind_1 = require("./ContentKind");
|
|
10
|
-
const Context_1 = require("./Context");
|
|
11
|
-
const Stub_1 = require("./Stub");
|
|
12
|
-
const Time_1 = require("./Time");
|
|
13
|
-
var WorkspaceStubArrayKey;
|
|
14
|
-
(function (WorkspaceStubArrayKey) {
|
|
15
|
-
WorkspaceStubArrayKey["BOOKS"] = "books";
|
|
16
|
-
WorkspaceStubArrayKey["SHORTS"] = "shorts";
|
|
17
|
-
WorkspaceStubArrayKey["ARTICLES"] = "articles";
|
|
18
|
-
WorkspaceStubArrayKey["POEMS"] = "poems";
|
|
19
|
-
WorkspaceStubArrayKey["IDEAS"] = "ideas";
|
|
20
|
-
WorkspaceStubArrayKey["TRASH"] = "trash";
|
|
21
|
-
})(WorkspaceStubArrayKey || (exports.WorkspaceStubArrayKey = WorkspaceStubArrayKey = {}));
|
|
22
|
-
class Workspace extends Context_1.Context {
|
|
23
|
-
constructor(doc, shouldAcquire, shareSync) {
|
|
24
|
-
super(doc, shouldAcquire, shareSync);
|
|
25
|
-
this._articlesView = new ArrayView_1.ArrayView(this, ['payload', 'articles']);
|
|
26
|
-
this._booksView = new ArrayView_1.ArrayView(this, ['payload', 'books']);
|
|
27
|
-
this._ideasView = new ArrayView_1.ArrayView(this, ['payload', 'ideas']);
|
|
28
|
-
this._poemsView = new ArrayView_1.ArrayView(this, ['payload', 'poems']);
|
|
29
|
-
this._shortsView = new ArrayView_1.ArrayView(this, ['payload', 'shorts']);
|
|
30
|
-
this._devicesView = new ArrayView_1.ArrayView(this, ['payload', 'devices']);
|
|
31
|
-
this._sessionsView = new ArrayView_1.ArrayView(this, ['payload', 'sessions']);
|
|
32
|
-
}
|
|
33
|
-
get payload() {
|
|
34
|
-
return this.doc.data.payload;
|
|
35
|
-
}
|
|
36
|
-
static makeWorkspaceId(userId) {
|
|
37
|
-
return CachingHasher_1.CachingHasher.makeMd5ContentId(userId + "-" + ContentKind_1.ContentKind.WORKSPACE);
|
|
38
|
-
}
|
|
39
|
-
static create(userId, deviceId) {
|
|
40
|
-
const now = Time_1.MultiClock.now();
|
|
41
|
-
const workspaceId = Workspace.makeWorkspaceId(userId);
|
|
42
|
-
return ShareSync_1.ShareSyncFactory.get().createContent({
|
|
43
|
-
meta: {
|
|
44
|
-
ref: workspaceId,
|
|
45
|
-
is_head: true,
|
|
46
|
-
kind: ContentKind_1.ContentKind.WORKSPACE,
|
|
47
|
-
id: workspaceId,
|
|
48
|
-
owner: userId,
|
|
49
|
-
created_at: now,
|
|
50
|
-
updated_at: now
|
|
51
|
-
},
|
|
52
|
-
payload: {
|
|
53
|
-
devices: [deviceId],
|
|
54
|
-
journey: {},
|
|
55
|
-
books: [],
|
|
56
|
-
shorts: [],
|
|
57
|
-
articles: [],
|
|
58
|
-
poems: [],
|
|
59
|
-
ideas: [],
|
|
60
|
-
sessions: [],
|
|
61
|
-
trash: []
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
ensureLatestSchema() {
|
|
66
|
-
let batch = null;
|
|
67
|
-
if (this.payload.hasOwnProperty('primary_device')) {
|
|
68
|
-
if (!batch) {
|
|
69
|
-
batch = new Operation_1.BatchOperation(this);
|
|
70
|
-
}
|
|
71
|
-
batch.removeValueAtPath(['payload', 'primary_device']);
|
|
72
|
-
}
|
|
73
|
-
if (this.payload.hasOwnProperty('primary_device_last_update')) {
|
|
74
|
-
if (!batch) {
|
|
75
|
-
batch = new Operation_1.BatchOperation(this);
|
|
76
|
-
}
|
|
77
|
-
batch.removeValueAtPath(['payload', 'primary_device_last_update']);
|
|
78
|
-
}
|
|
79
|
-
if (!this.payload.hasOwnProperty('journey')) {
|
|
80
|
-
if (!batch) {
|
|
81
|
-
batch = new Operation_1.BatchOperation(this);
|
|
82
|
-
}
|
|
83
|
-
batch.setPathValue(['payload', 'journey'], {});
|
|
84
|
-
}
|
|
85
|
-
if (batch != null) {
|
|
86
|
-
batch.commit();
|
|
87
|
-
}
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
get articles() {
|
|
91
|
-
this.checkDisposed("Workspace.articles");
|
|
92
|
-
return this._articlesView;
|
|
93
|
-
}
|
|
94
|
-
get books() {
|
|
95
|
-
this.checkDisposed("Workspace.books");
|
|
96
|
-
return this._booksView;
|
|
97
|
-
}
|
|
98
|
-
get ideas() {
|
|
99
|
-
this.checkDisposed("Workspace.ideas");
|
|
100
|
-
return this._ideasView;
|
|
101
|
-
}
|
|
102
|
-
get poems() {
|
|
103
|
-
this.checkDisposed("Workspace.poems");
|
|
104
|
-
return this._poemsView;
|
|
105
|
-
}
|
|
106
|
-
get shorts() {
|
|
107
|
-
this.checkDisposed("Workspace.shorts");
|
|
108
|
-
return this._shortsView;
|
|
109
|
-
}
|
|
110
|
-
get sessions() {
|
|
111
|
-
this.checkDisposed("Workspace.sessions");
|
|
112
|
-
return this._sessionsView;
|
|
113
|
-
}
|
|
114
|
-
getStubArrayKeys() {
|
|
115
|
-
return [
|
|
116
|
-
WorkspaceStubArrayKey.ARTICLES,
|
|
117
|
-
WorkspaceStubArrayKey.BOOKS,
|
|
118
|
-
WorkspaceStubArrayKey.IDEAS,
|
|
119
|
-
WorkspaceStubArrayKey.POEMS,
|
|
120
|
-
WorkspaceStubArrayKey.SHORTS,
|
|
121
|
-
WorkspaceStubArrayKey.TRASH
|
|
122
|
-
];
|
|
123
|
-
}
|
|
124
|
-
getStubArrayView(key) {
|
|
125
|
-
this.checkDisposed("Workspace.getStubArrayView");
|
|
126
|
-
if (key === WorkspaceStubArrayKey.ARTICLES) {
|
|
127
|
-
return this.articles;
|
|
128
|
-
}
|
|
129
|
-
else if (key === WorkspaceStubArrayKey.BOOKS) {
|
|
130
|
-
return this.books;
|
|
131
|
-
}
|
|
132
|
-
else if (key === WorkspaceStubArrayKey.IDEAS) {
|
|
133
|
-
return this.ideas;
|
|
134
|
-
}
|
|
135
|
-
else if (key === WorkspaceStubArrayKey.POEMS) {
|
|
136
|
-
return this.poems;
|
|
137
|
-
}
|
|
138
|
-
else if (key === WorkspaceStubArrayKey.SHORTS) {
|
|
139
|
-
return this.shorts;
|
|
140
|
-
}
|
|
141
|
-
else if (key === WorkspaceStubArrayKey.TRASH) {
|
|
142
|
-
return this.trash;
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
// NOTE: As the user adds devices, we will always add new devices to the end of the array.
|
|
147
|
-
// So the most-recently-added device will always be at the end.
|
|
148
|
-
get devices() {
|
|
149
|
-
this.checkDisposed("Workspace.devices");
|
|
150
|
-
return this._devicesView;
|
|
151
|
-
}
|
|
152
|
-
addBook(book, activeId) {
|
|
153
|
-
this.checkDisposed("Workspace.addBook");
|
|
154
|
-
Stub_1.Stubs.insertStubAtActivePoint(book.asStub(), this._booksView, null, activeId, true);
|
|
155
|
-
}
|
|
156
|
-
addFragment(fragment, stubArrayKey, activeId) {
|
|
157
|
-
this.checkDisposed("Workspace.addFragment");
|
|
158
|
-
const stubArrayView = this.getStubArrayView(stubArrayKey);
|
|
159
|
-
const stub = fragment.asStub();
|
|
160
|
-
Stub_1.Stubs.insertStubAtActivePoint(stub, stubArrayView, fragment.category, activeId, true);
|
|
161
|
-
}
|
|
162
|
-
async acquireSessionsFromDate(sessionId, localDate) {
|
|
163
|
-
this.checkDisposed("Workspace.loadSessionsFromDate");
|
|
164
|
-
const shareSync = ShareSync_1.ShareSyncFactory.get();
|
|
165
|
-
const sessions = [];
|
|
166
|
-
for (let i = 0, len = this.sessions.length; i < len; i++) {
|
|
167
|
-
const sessionCreatedAt = this.sessions.get(i);
|
|
168
|
-
const sessionCreatedLocalDate = Time_1.Time.dateFrom(sessionCreatedAt.local_time);
|
|
169
|
-
if (localDate == sessionCreatedLocalDate) {
|
|
170
|
-
const sessionRef = Content_1.Content.makeContentRef(sessionId, sessionCreatedAt.utc_time);
|
|
171
|
-
const session = await shareSync.acquire(ContentKind_1.ContentKind.SESSION, sessionRef);
|
|
172
|
-
sessions.push(session);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return sessions;
|
|
176
|
-
}
|
|
177
|
-
isBookFolderId(id) {
|
|
178
|
-
this.checkDisposed("Workspace.isBookFolderId");
|
|
179
|
-
for (let i = 0, len = this.books.length; i < len; i++) {
|
|
180
|
-
const stub = this.books.get(i);
|
|
181
|
-
if (Stub_1.Stubs.isFolderStub(stub) && stub.id === id) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
hasJourneyDate(journeyKey) {
|
|
188
|
-
this.checkDisposed("Workspace.hasJourneyDate");
|
|
189
|
-
return this.payload.hasOwnProperty('journey') && this.payload.journey.hasOwnProperty(journeyKey);
|
|
190
|
-
}
|
|
191
|
-
getJourneyDate(journeyKey) {
|
|
192
|
-
this.checkDisposed("Workspace.getJourneyDate");
|
|
193
|
-
if (this.payload.hasOwnProperty('journey')) {
|
|
194
|
-
if (this.payload.journey.hasOwnProperty(journeyKey)) {
|
|
195
|
-
return this.payload.journey[journeyKey];
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
setJourneyDate(journeyKey, journeyDate) {
|
|
201
|
-
this.checkDisposed("Workspace.setJourneyDate");
|
|
202
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
203
|
-
if (this.payload.hasOwnProperty('journey')) {
|
|
204
|
-
batch.setPathValue(['payload', 'journey', journeyKey], journeyDate);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
const journey = {};
|
|
208
|
-
journey[journeyKey] = journeyDate;
|
|
209
|
-
batch.setPathValue(['payload', 'journey'], journey);
|
|
210
|
-
}
|
|
211
|
-
batch.commit();
|
|
212
|
-
}
|
|
213
|
-
mergeIncomingContext(incomingWorkspace) {
|
|
214
|
-
let madeChanges = super.mergeIncomingContext(incomingWorkspace);
|
|
215
|
-
// Collect all the session timestamps already in this workspace.
|
|
216
|
-
const sessionUtcTimes = new Set();
|
|
217
|
-
this.sessions.forEach((idx, sessionAt) => {
|
|
218
|
-
sessionUtcTimes.add(sessionAt.utc_time);
|
|
219
|
-
});
|
|
220
|
-
// Now add any new session timestamps from the incoming workspace.
|
|
221
|
-
const incomingSessions = incomingWorkspace.payload.sessions;
|
|
222
|
-
for (let i = 0, len = incomingSessions.length; i < len; i++) {
|
|
223
|
-
const incomingSessionAt = incomingSessions[i];
|
|
224
|
-
if (!sessionUtcTimes.has(incomingSessionAt.utc_time)) {
|
|
225
|
-
if (i < this.sessions.length) {
|
|
226
|
-
this.sessions.insert(i, incomingSessionAt);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
this.sessions.push(incomingSessionAt);
|
|
230
|
-
}
|
|
231
|
-
madeChanges = true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return madeChanges;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.Workspace = Workspace;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export * from './Activity';
|
|
2
|
-
export * from './ArrayView';
|
|
3
|
-
export * from './Billing';
|
|
4
|
-
export * from './Book';
|
|
5
|
-
export * from './Category';
|
|
6
|
-
export * from './Checkpointable';
|
|
7
|
-
export * from './Comment';
|
|
8
|
-
export * from './ConceptArt';
|
|
9
|
-
export * from './Content';
|
|
10
|
-
export * from './ContentKind';
|
|
11
|
-
export * from './Context';
|
|
12
|
-
export * from './DevEnv';
|
|
13
|
-
export * from './Device';
|
|
14
|
-
export * from './Dictionary';
|
|
15
|
-
export * from './ElasticModel';
|
|
16
|
-
export * from './Environment';
|
|
17
|
-
export * from './ExportOptions';
|
|
18
|
-
export * from './Folder';
|
|
19
|
-
export * from './Fragment';
|
|
20
|
-
export * from './GeoLocation';
|
|
21
|
-
export * from './HighlightRule';
|
|
22
|
-
export * from './Manifest';
|
|
23
|
-
export * from './Media';
|
|
24
|
-
export * from './Metric';
|
|
25
|
-
export * from './Migration';
|
|
26
|
-
export * from './Model';
|
|
27
|
-
export * from './Permissions';
|
|
28
|
-
export * from './Placeholder';
|
|
29
|
-
export * from './Profile';
|
|
30
|
-
export * from './RichText';
|
|
31
|
-
export * from './Session';
|
|
32
|
-
export * from './Speech';
|
|
33
|
-
export * from './Stub';
|
|
34
|
-
export * from './Time';
|
|
35
|
-
export * from './User';
|
|
36
|
-
export * from './Workspace';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// created from 'create-ts-index'
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./Activity"), exports);
|
|
19
|
-
__exportStar(require("./ArrayView"), exports);
|
|
20
|
-
__exportStar(require("./Billing"), exports);
|
|
21
|
-
__exportStar(require("./Book"), exports);
|
|
22
|
-
__exportStar(require("./Category"), exports);
|
|
23
|
-
__exportStar(require("./Checkpointable"), exports);
|
|
24
|
-
__exportStar(require("./Comment"), exports);
|
|
25
|
-
__exportStar(require("./ConceptArt"), exports);
|
|
26
|
-
__exportStar(require("./Content"), exports);
|
|
27
|
-
__exportStar(require("./ContentKind"), exports);
|
|
28
|
-
__exportStar(require("./Context"), exports);
|
|
29
|
-
__exportStar(require("./DevEnv"), exports);
|
|
30
|
-
__exportStar(require("./Device"), exports);
|
|
31
|
-
__exportStar(require("./Dictionary"), exports);
|
|
32
|
-
__exportStar(require("./ElasticModel"), exports);
|
|
33
|
-
__exportStar(require("./Environment"), exports);
|
|
34
|
-
__exportStar(require("./ExportOptions"), exports);
|
|
35
|
-
__exportStar(require("./Folder"), exports);
|
|
36
|
-
__exportStar(require("./Fragment"), exports);
|
|
37
|
-
__exportStar(require("./GeoLocation"), exports);
|
|
38
|
-
__exportStar(require("./HighlightRule"), exports);
|
|
39
|
-
__exportStar(require("./Manifest"), exports);
|
|
40
|
-
__exportStar(require("./Media"), exports);
|
|
41
|
-
__exportStar(require("./Metric"), exports);
|
|
42
|
-
__exportStar(require("./Migration"), exports);
|
|
43
|
-
__exportStar(require("./Model"), exports);
|
|
44
|
-
__exportStar(require("./Permissions"), exports);
|
|
45
|
-
__exportStar(require("./Placeholder"), exports);
|
|
46
|
-
__exportStar(require("./Profile"), exports);
|
|
47
|
-
__exportStar(require("./RichText"), exports);
|
|
48
|
-
__exportStar(require("./Session"), exports);
|
|
49
|
-
__exportStar(require("./Speech"), exports);
|
|
50
|
-
__exportStar(require("./Stub"), exports);
|
|
51
|
-
__exportStar(require("./Time"), exports);
|
|
52
|
-
__exportStar(require("./User"), exports);
|
|
53
|
-
__exportStar(require("./Workspace"), exports);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Format } from "../content/RichText";
|
|
2
|
-
import { LegacyContent } from "./LegacyContent";
|
|
3
|
-
export interface LegacyBodyFormatPayload {
|
|
4
|
-
body: string;
|
|
5
|
-
format: Format[];
|
|
6
|
-
}
|
|
7
|
-
export interface LegacyBodyFormat extends LegacyContent {
|
|
8
|
-
payload: LegacyBodyFormatPayload;
|
|
9
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MultiTime } from "../content/Time";
|
|
2
|
-
import { LegacyBodyFormat, LegacyBodyFormatPayload } from "./LegacyBodyFormat";
|
|
3
|
-
import { LegacyHeadLocator, LegacyLocator } from "./LegacyLocator";
|
|
4
|
-
export interface LegacyCommentPayload extends LegacyBodyFormatPayload {
|
|
5
|
-
anchor: LegacyLocator | null;
|
|
6
|
-
word_count: number;
|
|
7
|
-
by: LegacyHeadLocator;
|
|
8
|
-
at: MultiTime;
|
|
9
|
-
}
|
|
10
|
-
export interface LegacyComment extends LegacyBodyFormat {
|
|
11
|
-
payload: LegacyCommentPayload;
|
|
12
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { CompactDateTime, MultiTime } from "../content/Time";
|
|
2
|
-
import { LegacyBodyFormatPayload } from "./LegacyBodyFormat";
|
|
3
|
-
import { LegacyCommentPayload } from "./LegacyComment";
|
|
4
|
-
import { LegacyFragmentPayload } from "./LegacyFragment";
|
|
5
|
-
import { LegacyHeadLocator, LegacyLocator } from "./LegacyLocator";
|
|
6
|
-
import { LegacyPicturePayload } from "./LegacyPicture";
|
|
7
|
-
import { LegacyProfilePayload } from "./LegacyProfile";
|
|
8
|
-
import { LegacySessionPayload } from "./LegacySession";
|
|
9
|
-
import { LegacyStoryPayload } from "./LegacyStory";
|
|
10
|
-
import { LegacyTransactionPayload } from "./LegacyTransaction";
|
|
11
|
-
import { LegacyUserPayload } from "./LegacyUser";
|
|
12
|
-
import { LegacyWorkspacePayload } from "./LegacyWorkspace";
|
|
13
|
-
export type LegacyDateTime = string;
|
|
14
|
-
export declare class LegacyClock {
|
|
15
|
-
static utcNow(): LegacyDateTime;
|
|
16
|
-
static fromCompact(value: CompactDateTime): LegacyDateTime;
|
|
17
|
-
}
|
|
18
|
-
export declare class LegacyMultiClock {
|
|
19
|
-
static utcNow(): LegacyMultiTime;
|
|
20
|
-
static fromModern(multiTime: MultiTime): LegacyMultiTime;
|
|
21
|
-
}
|
|
22
|
-
export interface LegacyMultiTime {
|
|
23
|
-
utc_time: LegacyDateTime;
|
|
24
|
-
local_time: LegacyDateTime;
|
|
25
|
-
}
|
|
26
|
-
export type LegacyPayload = LegacyBodyFormatPayload | LegacyCommentPayload | LegacyFragmentPayload | LegacyPicturePayload | LegacyStoryPayload | LegacyWorkspacePayload | LegacyProfilePayload | LegacySessionPayload | LegacyTransactionPayload | LegacyUserPayload;
|
|
27
|
-
export declare enum LegacyContentKind {
|
|
28
|
-
COMMENT = "comment",
|
|
29
|
-
FOLDER = "folder",
|
|
30
|
-
FRAGMENT = "fragment",
|
|
31
|
-
PICTURE = "picture",
|
|
32
|
-
PROFILE = "profile",
|
|
33
|
-
SESSION = "session",
|
|
34
|
-
STORY = "story",
|
|
35
|
-
TRANSACTION = "transaction",
|
|
36
|
-
USER = "user",
|
|
37
|
-
WORKSPACE = "workspace"
|
|
38
|
-
}
|
|
39
|
-
export interface LegacyContent {
|
|
40
|
-
locator: LegacyLocator;
|
|
41
|
-
parent: LegacyLocator | null;
|
|
42
|
-
is_head: boolean;
|
|
43
|
-
sync_time: string | null;
|
|
44
|
-
kind: LegacyContentKind;
|
|
45
|
-
id: LegacyHeadLocator;
|
|
46
|
-
seq: number;
|
|
47
|
-
by: LegacyHeadLocator;
|
|
48
|
-
at: LegacyMultiTime;
|
|
49
|
-
model_version: number;
|
|
50
|
-
session: LegacyLocator | null;
|
|
51
|
-
permissions: string[];
|
|
52
|
-
payload: LegacyPayload;
|
|
53
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LegacyContentKind = exports.LegacyMultiClock = exports.LegacyClock = void 0;
|
|
7
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
-
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
9
|
-
dayjs_1.default.extend(utc_1.default);
|
|
10
|
-
const Time_1 = require("../content/Time");
|
|
11
|
-
class LegacyClock {
|
|
12
|
-
static utcNow() {
|
|
13
|
-
return dayjs_1.default.utc().format(Time_1.Time.DATETIME_FORMAT_LEGACY);
|
|
14
|
-
}
|
|
15
|
-
static fromCompact(value) {
|
|
16
|
-
return dayjs_1.default.utc(value, Time_1.Time.DATETIME_FORMAT_COMPACT).format(Time_1.Time.DATETIME_FORMAT_LEGACY);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.LegacyClock = LegacyClock;
|
|
20
|
-
class LegacyMultiClock {
|
|
21
|
-
static utcNow() {
|
|
22
|
-
let nowUtc = dayjs_1.default.utc().format(Time_1.Time.DATETIME_FORMAT_LEGACY);
|
|
23
|
-
const timestamp = dayjs_1.default.utc(nowUtc, Time_1.Time.DATETIME_FORMAT_LEGACY)
|
|
24
|
-
.local();
|
|
25
|
-
let nowLocal = timestamp.format(Time_1.Time.DATETIME_FORMAT_LEGACY);
|
|
26
|
-
return {
|
|
27
|
-
local_time: nowLocal,
|
|
28
|
-
utc_time: nowUtc
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// TODO: Is this correct? It's going to return zero-offset (UTC zone)
|
|
32
|
-
// timestamps for both utc_time and local_time, no matter what the inputs
|
|
33
|
-
// are... Perhaps we can just delete this method, it is not even being used,
|
|
34
|
-
// as far as I can tell
|
|
35
|
-
static fromModern(multiTime) {
|
|
36
|
-
return {
|
|
37
|
-
utc_time: LegacyClock.fromCompact(multiTime.utc_time),
|
|
38
|
-
local_time: LegacyClock.fromCompact(multiTime.local_time),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.LegacyMultiClock = LegacyMultiClock;
|
|
43
|
-
var LegacyContentKind;
|
|
44
|
-
(function (LegacyContentKind) {
|
|
45
|
-
LegacyContentKind["COMMENT"] = "comment";
|
|
46
|
-
LegacyContentKind["FOLDER"] = "folder";
|
|
47
|
-
LegacyContentKind["FRAGMENT"] = "fragment";
|
|
48
|
-
LegacyContentKind["PICTURE"] = "picture";
|
|
49
|
-
LegacyContentKind["PROFILE"] = "profile";
|
|
50
|
-
LegacyContentKind["SESSION"] = "session";
|
|
51
|
-
LegacyContentKind["STORY"] = "story";
|
|
52
|
-
LegacyContentKind["TRANSACTION"] = "transaction";
|
|
53
|
-
LegacyContentKind["USER"] = "user";
|
|
54
|
-
LegacyContentKind["WORKSPACE"] = "workspace";
|
|
55
|
-
})(LegacyContentKind || (exports.LegacyContentKind = LegacyContentKind = {}));
|