@shaxpir/duiduidui-models 1.0.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.
Files changed (211) hide show
  1. package/README.md +1 -0
  2. package/decs.d.ts +87 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +20 -0
  5. package/dist/models/OutboundMessage.d.ts +18 -0
  6. package/dist/models/OutboundMessage.js +25 -0
  7. package/dist/models/content/Activity.d.ts +10 -0
  8. package/dist/models/content/Activity.js +2 -0
  9. package/dist/models/content/ArrayView.d.ts +26 -0
  10. package/dist/models/content/ArrayView.js +174 -0
  11. package/dist/models/content/Billing.d.ts +144 -0
  12. package/dist/models/content/Billing.js +418 -0
  13. package/dist/models/content/Book.d.ts +77 -0
  14. package/dist/models/content/Book.js +407 -0
  15. package/dist/models/content/Category.d.ts +16 -0
  16. package/dist/models/content/Category.js +20 -0
  17. package/dist/models/content/Checkpointable.d.ts +21 -0
  18. package/dist/models/content/Checkpointable.js +156 -0
  19. package/dist/models/content/Comment.d.ts +19 -0
  20. package/dist/models/content/Comment.js +53 -0
  21. package/dist/models/content/ConceptArt.d.ts +31 -0
  22. package/dist/models/content/ConceptArt.js +84 -0
  23. package/dist/models/content/Content.d.ts +52 -0
  24. package/dist/models/content/Content.js +61 -0
  25. package/dist/models/content/ContentKind.d.ts +10 -0
  26. package/dist/models/content/ContentKind.js +16 -0
  27. package/dist/models/content/Context.d.ts +28 -0
  28. package/dist/models/content/Context.js +162 -0
  29. package/dist/models/content/DevEnv.d.ts +5 -0
  30. package/dist/models/content/DevEnv.js +9 -0
  31. package/dist/models/content/Device.d.ts +24 -0
  32. package/dist/models/content/Device.js +62 -0
  33. package/dist/models/content/Dictionary.d.ts +31 -0
  34. package/dist/models/content/Dictionary.js +5 -0
  35. package/dist/models/content/DictionaryEntry.d.ts +20 -0
  36. package/dist/models/content/DictionaryEntry.js +2 -0
  37. package/dist/models/content/ElasticModel.d.ts +149 -0
  38. package/dist/models/content/ElasticModel.js +179 -0
  39. package/dist/models/content/Environment.d.ts +61 -0
  40. package/dist/models/content/Environment.js +124 -0
  41. package/dist/models/content/ExportOptions.d.ts +64 -0
  42. package/dist/models/content/ExportOptions.js +213 -0
  43. package/dist/models/content/Folder.d.ts +16 -0
  44. package/dist/models/content/Folder.js +33 -0
  45. package/dist/models/content/Fragment.d.ts +54 -0
  46. package/dist/models/content/Fragment.js +181 -0
  47. package/dist/models/content/GeoLocation.d.ts +4 -0
  48. package/dist/models/content/GeoLocation.js +2 -0
  49. package/dist/models/content/Hanzi.d.ts +21 -0
  50. package/dist/models/content/Hanzi.js +2 -0
  51. package/dist/models/content/HighlightRule.d.ts +9 -0
  52. package/dist/models/content/HighlightRule.js +2 -0
  53. package/dist/models/content/Manifest.d.ts +42 -0
  54. package/dist/models/content/Manifest.js +114 -0
  55. package/dist/models/content/Media.d.ts +32 -0
  56. package/dist/models/content/Media.js +98 -0
  57. package/dist/models/content/Metric.d.ts +46 -0
  58. package/dist/models/content/Metric.js +183 -0
  59. package/dist/models/content/Migration.d.ts +68 -0
  60. package/dist/models/content/Migration.js +155 -0
  61. package/dist/models/content/Model.d.ts +45 -0
  62. package/dist/models/content/Model.js +280 -0
  63. package/dist/models/content/Permissions.d.ts +7 -0
  64. package/dist/models/content/Permissions.js +20 -0
  65. package/dist/models/content/Phrase.d.ts +8 -0
  66. package/dist/models/content/Phrase.js +2 -0
  67. package/dist/models/content/Placeholder.d.ts +8 -0
  68. package/dist/models/content/Placeholder.js +36 -0
  69. package/dist/models/content/Profile.d.ts +30 -0
  70. package/dist/models/content/Profile.js +95 -0
  71. package/dist/models/content/RichText.d.ts +58 -0
  72. package/dist/models/content/RichText.js +79 -0
  73. package/dist/models/content/Session.d.ts +39 -0
  74. package/dist/models/content/Session.js +173 -0
  75. package/dist/models/content/Speech.d.ts +67 -0
  76. package/dist/models/content/Speech.js +97 -0
  77. package/dist/models/content/Stub.d.ts +24 -0
  78. package/dist/models/content/Stub.js +179 -0
  79. package/dist/models/content/Time.d.ts +56 -0
  80. package/dist/models/content/Time.js +295 -0
  81. package/dist/models/content/User.d.ts +36 -0
  82. package/dist/models/content/User.js +95 -0
  83. package/dist/models/content/Workspace.d.ts +71 -0
  84. package/dist/models/content/Workspace.js +237 -0
  85. package/dist/models/content/index.d.ts +36 -0
  86. package/dist/models/content/index.js +53 -0
  87. package/dist/models/index.d.ts +4 -0
  88. package/dist/models/index.js +21 -0
  89. package/dist/models/legacy/LegacyBodyFormat.d.ts +9 -0
  90. package/dist/models/legacy/LegacyBodyFormat.js +2 -0
  91. package/dist/models/legacy/LegacyComment.d.ts +12 -0
  92. package/dist/models/legacy/LegacyComment.js +2 -0
  93. package/dist/models/legacy/LegacyContent.d.ts +53 -0
  94. package/dist/models/legacy/LegacyContent.js +55 -0
  95. package/dist/models/legacy/LegacyConversion.d.ts +55 -0
  96. package/dist/models/legacy/LegacyConversion.js +401 -0
  97. package/dist/models/legacy/LegacyFragment.d.ts +21 -0
  98. package/dist/models/legacy/LegacyFragment.js +2 -0
  99. package/dist/models/legacy/LegacyLocator.d.ts +8 -0
  100. package/dist/models/legacy/LegacyLocator.js +31 -0
  101. package/dist/models/legacy/LegacyOutboundMessage.d.ts +16 -0
  102. package/dist/models/legacy/LegacyOutboundMessage.js +13 -0
  103. package/dist/models/legacy/LegacyPicture.d.ts +14 -0
  104. package/dist/models/legacy/LegacyPicture.js +2 -0
  105. package/dist/models/legacy/LegacyProfile.d.ts +9 -0
  106. package/dist/models/legacy/LegacyProfile.js +2 -0
  107. package/dist/models/legacy/LegacySession.d.ts +41 -0
  108. package/dist/models/legacy/LegacySession.js +35 -0
  109. package/dist/models/legacy/LegacyStory.d.ts +23 -0
  110. package/dist/models/legacy/LegacyStory.js +2 -0
  111. package/dist/models/legacy/LegacyStub.d.ts +15 -0
  112. package/dist/models/legacy/LegacyStub.js +2 -0
  113. package/dist/models/legacy/LegacyTransaction.d.ts +14 -0
  114. package/dist/models/legacy/LegacyTransaction.js +49 -0
  115. package/dist/models/legacy/LegacyUser.d.ts +28 -0
  116. package/dist/models/legacy/LegacyUser.js +32 -0
  117. package/dist/models/legacy/LegacyWorkspace.d.ts +23 -0
  118. package/dist/models/legacy/LegacyWorkspace.js +6 -0
  119. package/dist/models/legacy/index.d.ts +15 -0
  120. package/dist/models/legacy/index.js +32 -0
  121. package/dist/models/markup/BodyFormat.d.ts +14 -0
  122. package/dist/models/markup/BodyFormat.js +190 -0
  123. package/dist/models/markup/ChangeModel.d.ts +22 -0
  124. package/dist/models/markup/ChangeModel.js +107 -0
  125. package/dist/models/markup/DeltaOps.d.ts +5 -0
  126. package/dist/models/markup/DeltaOps.js +74 -0
  127. package/dist/models/markup/HtmlMarkup.d.ts +4 -0
  128. package/dist/models/markup/HtmlMarkup.js +21 -0
  129. package/dist/models/markup/Operation.d.ts +32 -0
  130. package/dist/models/markup/Operation.js +194 -0
  131. package/dist/models/markup/TextEditOps.d.ts +9 -0
  132. package/dist/models/markup/TextEditOps.js +50 -0
  133. package/dist/models/markup/index.d.ts +6 -0
  134. package/dist/models/markup/index.js +23 -0
  135. package/dist/repo/ConnectionListener.d.ts +9 -0
  136. package/dist/repo/ConnectionListener.js +21 -0
  137. package/dist/repo/PermissiveJson1.d.ts +58 -0
  138. package/dist/repo/PermissiveJson1.js +39 -0
  139. package/dist/repo/ShareSync.d.ts +60 -0
  140. package/dist/repo/ShareSync.js +348 -0
  141. package/dist/repo/index.d.ts +3 -0
  142. package/dist/repo/index.js +20 -0
  143. package/dist/util/Async.d.ts +8 -0
  144. package/dist/util/Async.js +18 -0
  145. package/dist/util/Base62.d.ts +6 -0
  146. package/dist/util/Base62.js +47 -0
  147. package/dist/util/BinarySearch.d.ts +7 -0
  148. package/dist/util/BinarySearch.js +46 -0
  149. package/dist/util/CachingHasher.d.ts +8 -0
  150. package/dist/util/CachingHasher.js +41 -0
  151. package/dist/util/Color.d.ts +32 -0
  152. package/dist/util/Color.js +204 -0
  153. package/dist/util/Dispatch.d.ts +15 -0
  154. package/dist/util/Dispatch.js +79 -0
  155. package/dist/util/EditDistance.d.ts +13 -0
  156. package/dist/util/EditDistance.js +184 -0
  157. package/dist/util/Encryption.d.ts +5 -0
  158. package/dist/util/Encryption.js +2 -0
  159. package/dist/util/Logging.d.ts +108 -0
  160. package/dist/util/Logging.js +412 -0
  161. package/dist/util/NumberFormat.d.ts +14 -0
  162. package/dist/util/NumberFormat.js +224 -0
  163. package/dist/util/Struct.d.ts +4 -0
  164. package/dist/util/Struct.js +15 -0
  165. package/dist/util/Template.d.ts +16 -0
  166. package/dist/util/Template.js +128 -0
  167. package/dist/util/Text.d.ts +45 -0
  168. package/dist/util/Text.js +243 -0
  169. package/dist/util/Tuples.d.ts +9 -0
  170. package/dist/util/Tuples.js +135 -0
  171. package/dist/util/Validate.d.ts +4 -0
  172. package/dist/util/Validate.js +11 -0
  173. package/dist/util/Vocabulary.d.ts +3 -0
  174. package/dist/util/Vocabulary.js +35 -0
  175. package/dist/util/index.d.ts +16 -0
  176. package/dist/util/index.js +33 -0
  177. package/lib/models/content/ArrayView.ts +203 -0
  178. package/lib/models/content/Billing.ts +558 -0
  179. package/lib/models/content/Content.ts +110 -0
  180. package/lib/models/content/ContentKind.ts +14 -0
  181. package/lib/models/content/DevEnv.ts +5 -0
  182. package/lib/models/content/Device.ts +86 -0
  183. package/lib/models/content/DictionaryEntry.ts +22 -0
  184. package/lib/models/content/GeoLocation.ts +4 -0
  185. package/lib/models/content/Hanzi.ts +25 -0
  186. package/lib/models/content/Manifest.ts +162 -0
  187. package/lib/models/content/Media.ts +126 -0
  188. package/lib/models/content/Model.ts +327 -0
  189. package/lib/models/content/Permissions.ts +21 -0
  190. package/lib/models/content/Phrase.ts +10 -0
  191. package/lib/models/content/Profile.ts +119 -0
  192. package/lib/models/content/Time.ts +328 -0
  193. package/lib/models/content/User.ts +130 -0
  194. package/lib/models/markup/ChangeModel.ts +95 -0
  195. package/lib/models/markup/DeltaOps.ts +71 -0
  196. package/lib/models/markup/Operation.ts +215 -0
  197. package/lib/models/markup/TextEditOps.ts +50 -0
  198. package/lib/repo/ConnectionListener.ts +25 -0
  199. package/lib/repo/PermissiveJson1.ts +14 -0
  200. package/lib/repo/ShareSync.ts +390 -0
  201. package/lib/util/Base62.ts +47 -0
  202. package/lib/util/CachingHasher.ts +38 -0
  203. package/lib/util/Dispatch.ts +92 -0
  204. package/lib/util/Encryption.ts +5 -0
  205. package/lib/util/Logging.ts +568 -0
  206. package/lib/util/NumberFormat.ts +194 -0
  207. package/lib/util/Struct.ts +14 -0
  208. package/lib/util/Tuples.ts +131 -0
  209. package/package.json +41 -0
  210. package/tsconfig.json +25 -0
  211. package/tslint.json +46 -0
@@ -0,0 +1,203 @@
1
+ import { Struct } from "../../util/Struct";
2
+ import { BatchOperation, JsonPath, JsonPathSelect } from "../markup/Operation";
3
+ import { Content } from "./Content";
4
+
5
+ export class ArrayView<T> {
6
+
7
+ protected content:Content;
8
+ protected path:JsonPath;
9
+
10
+ constructor (content:Content, path:JsonPath) {
11
+ this.content = content;
12
+ this.path = path;
13
+ }
14
+
15
+ private get root():T[] {
16
+ this.content.checkDisposed("ArrayView.root");
17
+ return JsonPathSelect.getValueAtPath(this.content.doc, this.path);
18
+ }
19
+
20
+ public get length():number {
21
+ this.content.checkDisposed("ArrayView.length");
22
+ return this.root.length;
23
+ }
24
+
25
+ public get values():T[] {
26
+ this.content.checkDisposed("ArrayView.values");
27
+ return Struct.clone(this.root);
28
+ }
29
+
30
+ public get(idx:number):T {
31
+ this.content.checkDisposed("ArrayView.get");
32
+ return Struct.clone(this.root[idx]);
33
+ }
34
+
35
+ public indexOf(value:any):number {
36
+ this.content.checkDisposed("ArrayView.indexOf");
37
+ const array:T[] = JsonPathSelect.getValueAtPath(this.content.doc, this.path);
38
+ for (let i:number = 0; i < array.length; i++) {
39
+ if (array[i] == value) {
40
+ return i;
41
+ }
42
+ }
43
+ return -1;
44
+ }
45
+
46
+ public includes(value:any):boolean {
47
+ this.content.checkDisposed("ArrayView.includes");
48
+ const array:T[] = JsonPathSelect.getValueAtPath(this.content.doc, this.path);
49
+ for (let i:number = 0; i < array.length; i++) {
50
+ if (array[i] == value) {
51
+ return true;
52
+ }
53
+ }
54
+ return false;
55
+ }
56
+
57
+ public firstIndexWhere(
58
+ predicate:(value:T) => boolean
59
+ ):number {
60
+ this.content.checkDisposed("ArrayView.firstIndexWhere");
61
+ const array:T[] = JsonPathSelect.getValueAtPath(this.content.doc, this.path);
62
+ for (let i:number = 0; i < array.length; i++) {
63
+ if (predicate(array[i])) {
64
+ return i;
65
+ }
66
+ }
67
+ return -1;
68
+ }
69
+
70
+ public removeFirstWhere(
71
+ predicate:(value:T) => boolean
72
+ ):void {
73
+ this.content.checkDisposed("ArrayView.removeFirstWhere");
74
+ const index:number = this.firstIndexWhere(predicate);
75
+ this.removeAt(index);
76
+ }
77
+
78
+ public removeAllWhere(
79
+ predicate:(value:T) => boolean
80
+ ):void {
81
+ this.content.checkDisposed("ArrayView.removeAllWhere");
82
+ let foundMatch = false;
83
+ const batch = new BatchOperation(this.content);
84
+ const array:T[] = JsonPathSelect.getValueAtPath(this.content.doc, this.path);
85
+ for (let i:number = 0; i < array.length; i++) {
86
+ if (predicate(array[i])) {
87
+ const pathToElement:JsonPath = Struct.clone(this.path);
88
+ pathToElement.push(i);
89
+ batch.removeValueAtPath(pathToElement);
90
+ foundMatch = true;
91
+ }
92
+ }
93
+ if (foundMatch) {
94
+ batch.commit();
95
+ }
96
+ }
97
+
98
+ public forEach(
99
+ callback:(idx:number, value:T) => void
100
+ ):void {
101
+ this.content.checkDisposed("ArrayView.forEach");
102
+ const array:T[] = JsonPathSelect.getValueAtPath(this.content.doc, this.path);
103
+ for (let i:number = 0; i < array.length; i++) {
104
+ callback(i, array[i]);
105
+ }
106
+ }
107
+
108
+ public unshift(value:T):void {
109
+ this.content.checkDisposed("ArrayView.unshift");
110
+ const batch = new BatchOperation(this.content);
111
+ batch.unshiftIntoArray(this.path, value);
112
+ batch.commit();
113
+ }
114
+
115
+ public push(value:T):void {
116
+ this.content.checkDisposed("ArrayView.push");
117
+ const batch = new BatchOperation(this.content);
118
+ batch.pushIntoArray(this.path, value);
119
+ batch.commit();
120
+ }
121
+
122
+ public insert(idx:number, value:T):void {
123
+ this.content.checkDisposed("ArrayView.insert");
124
+ if (idx == this.length) {
125
+ this.push(value);
126
+ } else {
127
+ const batch = new BatchOperation(this.content);
128
+ batch.insertIntoArray(this.path, idx, value);
129
+ batch.commit();
130
+ }
131
+ }
132
+
133
+ public remove(value:T):void {
134
+ this.content.checkDisposed("ArrayView.remove");
135
+ const index:number = this.indexOf(value);
136
+ if (index >= 0) {
137
+ this.removeAt(index);
138
+ }
139
+ }
140
+
141
+ public removeAt(index:number):void {
142
+ this.content.checkDisposed("ArrayView.removeAt");
143
+ const pathToElement:JsonPath = Struct.clone(this.path);
144
+ pathToElement.push(index);
145
+ const batch = new BatchOperation(this.content);
146
+ batch.removeValueAtPath(pathToElement);
147
+ batch.commit();
148
+ }
149
+
150
+ public move(originIndex:number, destinationIndex:number):void {
151
+ this.content.checkDisposed("ArrayView.move");
152
+ if (originIndex != destinationIndex) {
153
+ const originPath:JsonPath = Struct.clone(this.path);
154
+ const destinationPath:JsonPath = Struct.clone(this.path);
155
+ originPath.push(originIndex);
156
+ destinationPath.push(destinationIndex);
157
+ const batch = new BatchOperation(this.content);
158
+ batch.move(originPath, destinationPath);
159
+ batch.commit();
160
+ }
161
+ }
162
+
163
+ public removeObjectPropertyAtIndex(index:number, fieldName:string):void {
164
+ this.content.checkDisposed("ArrayView.setObjectValueAtIndex");
165
+ const pathToElement:JsonPath = Struct.clone(this.path);
166
+ pathToElement.push(index);
167
+ const element:any = JsonPathSelect.getValueAtPath(this.content.doc, pathToElement);
168
+ if (element.hasOwnProperty(fieldName)) {
169
+ const pathToProperty:JsonPath = Struct.clone(this.path);
170
+ pathToProperty.push(fieldName);
171
+ const batch = new BatchOperation(this.content);
172
+ batch.removeValueAtPath(pathToProperty)
173
+ batch.commit();
174
+ }
175
+ }
176
+
177
+ public setObjectValueAtIndex(index:number, fieldName:string, newValue:any):void {
178
+ this.content.checkDisposed("ArrayView.setObjectValueAtIndex");
179
+ const pathToElement:JsonPath = Struct.clone(this.path);
180
+ pathToElement.push(index);
181
+ pathToElement.push(fieldName);
182
+ const prevValue:any = JsonPathSelect.getValueAtPath(this.content.doc, pathToElement);
183
+ if (!Struct.equals(prevValue, newValue)) {
184
+ const batch = new BatchOperation(this.content);
185
+ batch.setPathValue(pathToElement, newValue);
186
+ batch.commit();
187
+ }
188
+ }
189
+
190
+ public editObjectTextValueAtIndex(index:number, fieldName:string, newValue:string):void {
191
+ this.content.checkDisposed("ArrayView.editObjectTextValueAtIndex");
192
+ const pathToElement:JsonPath = Struct.clone(this.path);
193
+ pathToElement.push(index);
194
+ pathToElement.push(fieldName);
195
+ const prevValue:any = JsonPathSelect.getValueAtPath(this.content.doc, pathToElement);
196
+ if (!Struct.equals(prevValue, newValue)) {
197
+ const batch = new BatchOperation(this.content);
198
+ batch.editPathText(pathToElement, newValue);
199
+ batch.commit();
200
+ }
201
+ }
202
+
203
+ }