@twilio/conversations 1.3.0-rc8 → 2.0.0-rc.4

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 (282) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +22 -17
  3. package/dist/browser.js +7873 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/docs/assets/css/main.css +2660 -0
  6. package/dist/docs/assets/images/icons.png +0 -0
  7. package/dist/docs/assets/images/icons@2x.png +0 -0
  8. package/dist/docs/assets/images/widgets.png +0 -0
  9. package/dist/docs/assets/images/widgets@2x.png +0 -0
  10. package/dist/docs/assets/js/main.js +248 -0
  11. package/dist/docs/assets/js/search.js +1 -0
  12. package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
  13. package/dist/docs/classes/Client.html +4181 -0
  14. package/dist/docs/classes/Conversation.html +4397 -0
  15. package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
  16. package/dist/docs/classes/Media.html +3295 -0
  17. package/dist/docs/classes/Message.html +3713 -0
  18. package/dist/docs/classes/MessageBuilder.html +3280 -0
  19. package/dist/docs/classes/Participant.html +3517 -0
  20. package/dist/docs/classes/PushNotification.html +3232 -0
  21. package/dist/docs/classes/RestPaginator.html +3262 -0
  22. package/dist/docs/classes/UnsentMessage.html +3144 -0
  23. package/dist/docs/classes/User.html +3451 -0
  24. package/dist/docs/index.html +3394 -212
  25. package/dist/docs/interfaces/ClientOptions.html +3136 -0
  26. package/dist/docs/interfaces/ConversationState.html +3152 -0
  27. package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
  28. package/dist/docs/interfaces/LastMessage.html +3152 -0
  29. package/dist/docs/interfaces/Paginator.html +3243 -0
  30. package/dist/docs/interfaces/PushNotificationData.html +3168 -0
  31. package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
  32. package/dist/docs/interfaces/SendMediaOptions.html +3170 -0
  33. package/dist/docs/modules.html +3425 -0
  34. package/dist/lib.d.ts +1952 -0
  35. package/dist/lib.js +7873 -0
  36. package/dist/lib.js.map +1 -0
  37. package/dist/post-install.js +29 -0
  38. package/dist/react-native.js +4038 -0
  39. package/dist/react-native.js.map +1 -0
  40. package/dist/twilio-conversations.js +40912 -0
  41. package/dist/twilio-conversations.min.js +156 -0
  42. package/package.json +59 -48
  43. package/.circleci/config.yml +0 -650
  44. package/.deepsource.toml +0 -6
  45. package/.env.example +0 -13
  46. package/browser/aggregateddeliveryreceipt.js +0 -152
  47. package/browser/client.js +0 -991
  48. package/browser/configuration.js +0 -80
  49. package/browser/conversation.js +0 -1826
  50. package/browser/data/conversations.js +0 -632
  51. package/browser/data/messages.js +0 -522
  52. package/browser/data/participants.js +0 -411
  53. package/browser/data/users.js +0 -281
  54. package/browser/detaileddeliveryreceipt.js +0 -44
  55. package/browser/index.js +0 -4
  56. package/browser/interfaces/limits.js +0 -3
  57. package/browser/interfaces/notificationtypes.js +0 -21
  58. package/browser/interfaces/paginator.js +0 -53
  59. package/browser/interfaces/responsecodes.js +0 -20
  60. package/browser/interfaces/transport.js +0 -3
  61. package/browser/logger.js +0 -141
  62. package/browser/media.js +0 -198
  63. package/browser/message.js +0 -685
  64. package/browser/participant.js +0 -415
  65. package/browser/pushnotification.js +0 -49
  66. package/browser/restpaginator.js +0 -74
  67. package/browser/services/network.js +0 -223
  68. package/browser/services/readhorizon.js +0 -181
  69. package/browser/services/typingindicator.js +0 -142
  70. package/browser/session.js +0 -505
  71. package/browser/sessionerror.js +0 -93
  72. package/browser/sri.json +0 -1
  73. package/browser/synclist.js +0 -90
  74. package/browser/synclistdescriptor.js +0 -29
  75. package/browser/syncpaginator.js +0 -63
  76. package/browser/user.js +0 -431
  77. package/browser/util/deferred.js +0 -56
  78. package/browser/util/index.js +0 -108
  79. package/dist/@twilio/conversations.js +0 -35533
  80. package/dist/@twilio/conversations.min.js +0 -204
  81. package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
  82. package/dist/docs/Client.html +0 -5075
  83. package/dist/docs/Conversation.html +0 -6018
  84. package/dist/docs/DetailedDeliveryReceipt.html +0 -641
  85. package/dist/docs/Media.html +0 -694
  86. package/dist/docs/Message.html +0 -1934
  87. package/dist/docs/Paginator.html +0 -605
  88. package/dist/docs/Participant.html +0 -1510
  89. package/dist/docs/PushNotification.html +0 -836
  90. package/dist/docs/SessionError.html +0 -379
  91. package/dist/docs/User.html +0 -1315
  92. package/dist/docs/classes.list.html +0 -4431
  93. package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  94. package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
  95. package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  96. package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  97. package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  98. package/dist/docs/img/glyphicons-halflings-white.png +0 -0
  99. package/dist/docs/img/glyphicons-halflings.png +0 -0
  100. package/dist/docs/quicksearch.html +0 -31
  101. package/dist/docs/scripts/docstrap.lib.js +0 -11
  102. package/dist/docs/scripts/fulltext-search-ui.js +0 -89
  103. package/dist/docs/scripts/fulltext-search.js +0 -36
  104. package/dist/docs/scripts/lunr.min.js +0 -6
  105. package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  106. package/dist/docs/scripts/prettify/jquery.min.js +0 -6
  107. package/dist/docs/scripts/prettify/lang-css.js +0 -21
  108. package/dist/docs/scripts/prettify/prettify.js +0 -496
  109. package/dist/docs/scripts/sunlight.js +0 -1157
  110. package/dist/docs/scripts/toc.js +0 -203
  111. package/dist/docs/styles/darkstrap.css +0 -960
  112. package/dist/docs/styles/prettify-tomorrow.css +0 -132
  113. package/dist/docs/styles/site.cerulean.css +0 -7008
  114. package/dist/docs/styles/site.cosmo.css +0 -7061
  115. package/dist/docs/styles/site.cyborg.css +0 -7048
  116. package/dist/docs/styles/site.darkly.css +0 -7171
  117. package/dist/docs/styles/site.darkstrap.css +0 -5638
  118. package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
  119. package/dist/docs/styles/site.flatly.css +0 -7147
  120. package/dist/docs/styles/site.journal.css +0 -6973
  121. package/dist/docs/styles/site.lumen.css +0 -7298
  122. package/dist/docs/styles/site.paper.css +0 -7623
  123. package/dist/docs/styles/site.readable.css +0 -6997
  124. package/dist/docs/styles/site.sandstone.css +0 -7035
  125. package/dist/docs/styles/site.simplex.css +0 -7023
  126. package/dist/docs/styles/site.slate.css +0 -7343
  127. package/dist/docs/styles/site.spacelab.css +0 -7055
  128. package/dist/docs/styles/site.superhero.css +0 -7131
  129. package/dist/docs/styles/site.united.css +0 -6895
  130. package/dist/docs/styles/site.yeti.css +0 -7195
  131. package/dist/docs/styles/sunlight.dark.css +0 -345
  132. package/dist/docs/styles/sunlight.default.css +0 -344
  133. package/dist/sri.json +0 -1
  134. package/lib/aggregateddeliveryreceipt.d.ts +0 -98
  135. package/lib/aggregateddeliveryreceipt.js +0 -112
  136. package/lib/client.d.ts +0 -317
  137. package/lib/client.js +0 -633
  138. package/lib/configuration.d.ts +0 -21
  139. package/lib/configuration.js +0 -41
  140. package/lib/conversation.d.ts +0 -460
  141. package/lib/conversation.js +0 -940
  142. package/lib/data/conversations.d.ts +0 -57
  143. package/lib/data/conversations.js +0 -296
  144. package/lib/data/messages.d.ts +0 -75
  145. package/lib/data/messages.js +0 -208
  146. package/lib/data/participants.d.ts +0 -94
  147. package/lib/data/participants.js +0 -204
  148. package/lib/data/users.d.ts +0 -42
  149. package/lib/data/users.js +0 -113
  150. package/lib/detaileddeliveryreceipt.d.ts +0 -45
  151. package/lib/detaileddeliveryreceipt.js +0 -34
  152. package/lib/index.d.ts +0 -1
  153. package/lib/index.js +0 -3
  154. package/lib/interfaces/limits.d.ts +0 -8
  155. package/lib/interfaces/limits.js +0 -2
  156. package/lib/interfaces/notificationtypes.d.ts +0 -8
  157. package/lib/interfaces/notificationtypes.js +0 -11
  158. package/lib/interfaces/paginator.d.ts +0 -52
  159. package/lib/interfaces/paginator.js +0 -28
  160. package/lib/interfaces/responsecodes.d.ts +0 -8
  161. package/lib/interfaces/responsecodes.js +0 -10
  162. package/lib/interfaces/transport.d.ts +0 -13
  163. package/lib/interfaces/transport.js +0 -2
  164. package/lib/logger.d.ts +0 -18
  165. package/lib/logger.js +0 -35
  166. package/lib/media.d.ts +0 -52
  167. package/lib/media.js +0 -69
  168. package/lib/message.d.ts +0 -136
  169. package/lib/message.js +0 -305
  170. package/lib/participant.d.ts +0 -142
  171. package/lib/participant.js +0 -219
  172. package/lib/pushnotification.d.ts +0 -48
  173. package/lib/pushnotification.js +0 -39
  174. package/lib/restpaginator.d.ts +0 -19
  175. package/lib/restpaginator.js +0 -36
  176. package/lib/services/network.d.ts +0 -22
  177. package/lib/services/network.js +0 -87
  178. package/lib/services/readhorizon.d.ts +0 -28
  179. package/lib/services/readhorizon.js +0 -112
  180. package/lib/services/typingindicator.d.ts +0 -50
  181. package/lib/services/typingindicator.js +0 -102
  182. package/lib/session.d.ts +0 -63
  183. package/lib/session.js +0 -213
  184. package/lib/sessionerror.d.ts +0 -12
  185. package/lib/sessionerror.js +0 -24
  186. package/lib/sri.json +0 -1
  187. package/lib/synclist.d.ts +0 -24
  188. package/lib/synclist.js +0 -28
  189. package/lib/synclistdescriptor.d.ts +0 -27
  190. package/lib/synclistdescriptor.js +0 -19
  191. package/lib/syncpaginator.d.ts +0 -22
  192. package/lib/syncpaginator.js +0 -37
  193. package/lib/user.d.ts +0 -98
  194. package/lib/user.js +0 -219
  195. package/lib/util/deferred.d.ts +0 -12
  196. package/lib/util/deferred.js +0 -22
  197. package/lib/util/index.d.ts +0 -28
  198. package/lib/util/index.js +0 -82
  199. package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
  200. package/tools/rtd-sdk-cdn-pin/README.md +0 -54
  201. package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
  202. package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
  203. package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
  204. package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
  205. package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
  206. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
  207. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
  208. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
  209. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
  210. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
  211. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
  212. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
  213. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
  214. package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
  215. package/tools/sdk-release-tool/.gitrepo +0 -12
  216. package/tools/sdk-release-tool/Makefile +0 -49
  217. package/tools/sdk-release-tool/README.md +0 -275
  218. package/tools/sdk-release-tool/delete +0 -3
  219. package/tools/sdk-release-tool/download +0 -3
  220. package/tools/sdk-release-tool/get-cors +0 -3
  221. package/tools/sdk-release-tool/list +0 -3
  222. package/tools/sdk-release-tool/pin +0 -3
  223. package/tools/sdk-release-tool/pin-latest +0 -3
  224. package/tools/sdk-release-tool/requirements.txt +0 -4
  225. package/tools/sdk-release-tool/sdk-release-tool +0 -3
  226. package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
  227. package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
  228. package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
  229. package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
  230. package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
  231. package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
  232. package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
  233. package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
  234. package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
  235. package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
  236. package/tools/sdk-release-tool/tests/test_versions.py +0 -94
  237. package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
  238. package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
  239. package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
  240. package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
  241. package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
  242. package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
  243. package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
  244. package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
  245. package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
  246. package/tools/sdk-release-tool/twilio-client-android.json +0 -22
  247. package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
  248. package/tools/sdk-release-tool/twilio-client-js.json +0 -17
  249. package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
  250. package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
  251. package/tools/sdk-release-tool/twilio-common-android.json +0 -22
  252. package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
  253. package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
  254. package/tools/sdk-release-tool/twilio-common-js.json +0 -19
  255. package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
  256. package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
  257. package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
  258. package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
  259. package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
  260. package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
  261. package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
  262. package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
  263. package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
  264. package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
  265. package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
  266. package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
  267. package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
  268. package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
  269. package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
  270. package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
  271. package/tools/sdk-release-tool/twilio-video-android.json +0 -22
  272. package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
  273. package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
  274. package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
  275. package/tools/sdk-release-tool/twilio-video-js.json +0 -19
  276. package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
  277. package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
  278. package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
  279. package/tools/sdk-release-tool/unpin +0 -3
  280. package/tools/sdk-release-tool/unpin-latest +0 -3
  281. package/tools/sdk-release-tool/upload +0 -3
  282. package/twilio-chat.js.iml +0 -9
@@ -1,28 +0,0 @@
1
- from sdk_release_tools import log
2
- from sdk_release_tools.versions import parse_version
3
-
4
- import os
5
- import subprocess
6
-
7
-
8
- def get_version(rpm):
9
- rpm_cmd = 'rpm -qp --queryformat \'%{VERSION}\' ' + rpm
10
- rpm_version = subprocess.check_output(rpm_cmd, shell=True)
11
- rpm_version = rpm_version.replace('_', '-')
12
- if rpm_version.startswith('release-'):
13
- rpm_version = rpm_version[8:]
14
- return parse_version(rpm_version)
15
-
16
-
17
- def unpack(rpm, prefix=None):
18
- prefix = prefix or '/tmp/'
19
- version = get_version(rpm)
20
- dst = prefix + str(version)
21
- log.log(rpm)
22
- log.info(' Unpacking to ' + dst)
23
- unpack_cmd = (
24
- 'rm -rf {}; rpm2cpio {} | cpio -idmv; mv mnt {}'.format(dst, rpm, dst))
25
- FNULL = open(os.devnull, 'wb')
26
- subprocess.check_call(unpack_cmd, shell=True, stdout=FNULL, stderr=FNULL,
27
- close_fds=True)
28
- return dst
@@ -1,186 +0,0 @@
1
- from collections import OrderedDict
2
- from sdk_release_tools import ops
3
- from sdk_release_tools import rpm
4
- from sdk_release_tools.aws import get_bucket
5
- from sdk_release_tools.versions import parse_major_minor, parse_version
6
- import json
7
- import os
8
-
9
-
10
-
11
- def load_schema(schema_name):
12
- filepath = (schema_name if schema_name.endswith('.json') else
13
- '{}.json'.format(schema_name))
14
- with open(filepath) as schema_file:
15
- return json.loads(schema_file.read())
16
-
17
-
18
- def get_variables(schema, version):
19
- """
20
- Get the variables defined in the schema and merge them with any version
21
- number variables (e.g., "major", "minor", "patch", etc.).
22
- """
23
- variables = schema.get('variables', {})
24
- variables.update(version.__dict__)
25
- variables.update(version=str(version))
26
- return variables
27
-
28
-
29
- def delete(realm, schema, version, dry_run=True, silent=False):
30
- artifacts = schema.get('artifacts', {})
31
- variables = get_variables(schema, version)
32
- return ops.delete(artifacts, bucket=get_bucket(realm), variables=variables,
33
- dry_run=dry_run, silent=silent)
34
-
35
-
36
- def download(realm, schema, version, root, dry_run=True):
37
- artifacts = schema.get('artifacts', {})
38
- variables = get_variables(schema, version)
39
- return ops.download(artifacts, root=root, bucket=get_bucket(realm),
40
- variables=variables, dry_run=dry_run)
41
-
42
-
43
- def pin(realm, schema, version, dry_run=False):
44
- rules = schema.get('pin', {})
45
- variables = get_variables(schema, version)
46
- copy_on_pin = schema.get('copy_on_pin', False)
47
- return ops.pin(rules, bucket=get_bucket(realm), variables=variables,
48
- dry_run=dry_run, copy_on_pin=copy_on_pin)
49
-
50
-
51
- def pin_latest(realm, schema, version, dry_run=False):
52
- rules = schema.get('latest', {})
53
- variables = get_variables(schema, version)
54
- copy_on_pin = schema.get('copy_on_pin', False)
55
- return ops.pin(rules, bucket=get_bucket(realm), variables=variables,
56
- dry_run=dry_run, copy_on_pin=copy_on_pin)
57
-
58
-
59
- def unpin(realm, schema, version, dry_run=False):
60
- rules = schema.get('pin', {})
61
- variables = get_variables(schema, version)
62
- return ops.unpin(rules, bucket=get_bucket(realm), variables=variables,
63
- dry_run=dry_run)
64
-
65
-
66
- def unpin_latest(realm, schema, version, dry_run=False):
67
- rules = schema.get('latest', {})
68
- variables = get_variables(schema, version)
69
- return ops.unpin(rules, bucket=get_bucket(realm), variables=variables,
70
- dry_run=dry_run)
71
-
72
-
73
- def upload(realm, schema, version, root, dry_run=True):
74
- artifacts = schema.get('artifacts', {})
75
- variables = get_variables(schema, version)
76
- if not os.path.isdir(root):
77
- root = rpm.unpack(root)
78
- return ops.upload(artifacts, root=root, bucket=get_bucket(realm),
79
- variables=variables, dry_run=dry_run)
80
-
81
-
82
- def get_cors(realm):
83
- bucket = get_bucket(realm)
84
- return bucket.get_cors()
85
-
86
- def get_versions(realm, schema):
87
- bucket = get_bucket(realm)
88
- config = bucket.get_website_configuration_obj()
89
-
90
- unordered_versions = []
91
- versions_dir = schema.get('versions').format(**schema.get('variables', {}))
92
-
93
- for key in bucket.list(versions_dir, '/'):
94
- try:
95
- version = parse_version(os.path.split(key.name.rstrip('/'))[1])
96
- except:
97
- continue
98
- unordered_versions.append(version)
99
-
100
- ordered_versions = OrderedDict()
101
- for version in sorted(unordered_versions):
102
- ordered_versions[str(version)] = None
103
-
104
- major_minor_versions_dir = schema.get('major_minor_versions').format(
105
- **schema.get('variables', {}))
106
- ordered_major_minors = OrderedDict()
107
-
108
- latest = None
109
-
110
- # First, try to identify any versions pinned by S3 Key redirects.
111
- for key in bucket.list(major_minor_versions_dir, '/'):
112
- major_minor = None
113
- try:
114
- major_minor = parse_major_minor(
115
- os.path.split(key.name.rstrip('/'))[1])
116
- except:
117
- if os.path.split(key.name.rstrip('/'))[1] != "latest":
118
- continue
119
-
120
- # This is a little bit of a hack: we are going to iterate through the
121
- # prefixes until we find one that matches a key. Once we have the key,
122
- # we need to check if it has a redirect to a version number.
123
- version = None
124
- for key in bucket.list(key.name, '/'):
125
- if key.name.endswith('/'):
126
- continue
127
- key = bucket.get_key(key.name)
128
- if not key:
129
- continue
130
- redirect = key.get_redirect()
131
- if not redirect:
132
- continue
133
- if redirect.startswith('/' + versions_dir.lstrip('/')):
134
- redirect = redirect[len('/' + versions_dir.lstrip('/')):]
135
- try:
136
- version = parse_version(redirect.split('/')[0])
137
- except:
138
- continue
139
- break
140
-
141
- if not version:
142
- continue
143
-
144
- if not major_minor:
145
- latest = version
146
-
147
- version_str = str(version)
148
- if version_str in ordered_versions:
149
- ordered_versions[version_str] = major_minor
150
- ordered_major_minors[str(major_minor)] = version
151
-
152
- # Then, try to identify any versions pinned by RoutingRules (legacy).
153
- for rule in config.routing_rules:
154
- key_prefix = rule.condition.key_prefix
155
- if not key_prefix.startswith(major_minor_versions_dir):
156
- continue
157
-
158
- replace_key_prefix = rule.redirect.replace_key_prefix
159
-
160
- try:
161
- major_minor = parse_major_minor(
162
- os.path.split(key_prefix.rstrip('/'))[1])
163
- version = parse_version(
164
- os.path.split(replace_key_prefix.rstrip('/'))[1])
165
- except:
166
- continue
167
-
168
- version_str = str(version)
169
- if version_str in ordered_versions:
170
- ordered_versions[version_str] = major_minor
171
- ordered_major_minors[str(major_minor)] = version
172
-
173
- return (ordered_versions, ordered_major_minors, latest)
174
-
175
-
176
- def version_exists(realm, schema, version):
177
- ordered_versions, _, _ = get_versions(realm, schema)
178
- return str(version) in ordered_versions
179
-
180
-
181
- def get_pinned_by(realm, schema, version):
182
- """
183
- Get the major/minor pair that pins a version.
184
- """
185
- ordered_versions, _, _ = get_versions(realm, schema)
186
- return ordered_versions.get(str(version))
@@ -1,362 +0,0 @@
1
- from functools import total_ordering
2
-
3
- import re
4
-
5
-
6
- __all__ = ['Version', 'MajorMinor', 'MajorMinorPatch', 'SemVer',
7
- 'TwilioVersion', 'parse_major_minor', 'parse_version']
8
-
9
-
10
- def drop_leading_v(string):
11
- if string and string[0] == 'v':
12
- return string[1:]
13
- return string
14
-
15
-
16
- def contains_leading_zeroes(string):
17
- """
18
- Check if a string representing a digit contains leading zeroes.
19
- """
20
- return string.isdigit() and re.match(r'^0[0-9]', string)
21
-
22
-
23
- def parse_major_minor_patch(string):
24
- """
25
- Parse major, minor, and patch versions out of a string and return the rest.
26
- """
27
- match = re.match(r'^([0-9]+)\.([0-9]+)\.([0-9]+)', string)
28
-
29
- exception = ValueError(
30
- ('A normal version number MUST take the form X.Y.Z where X, Y, and Z '
31
- 'are non-negative integers, and MUST NOT contain leading zeroes: ' +
32
- string))
33
-
34
- if not match:
35
- raise exception
36
-
37
- identifiers = match.groups()
38
- if any([contains_leading_zeroes(identifier) for identifier in
39
- identifiers]):
40
- raise exception
41
-
42
- major = int(match.group(1))
43
- minor = int(match.group(2))
44
- patch = int(match.group(3))
45
- rest = string[match.end():]
46
-
47
- return (major, minor, patch, rest)
48
-
49
-
50
- class Version(object):
51
- def __ne__(self, other):
52
- return not self == other
53
-
54
-
55
- @total_ordering
56
- class MajorMinor(Version):
57
- """
58
- A version number with major and minor components, e.g.
59
-
60
- 1.2
61
-
62
- """
63
- def __eq__(self, other):
64
- return (self.major == other.major and
65
- self.minor == other.minor)
66
-
67
- def __init__(self, major, minor):
68
- self.major = major
69
- self.minor = minor
70
-
71
- def __le__(self, other):
72
- if self.major < other.major:
73
- return True
74
- elif self.major == other.major:
75
- return self.minor <= other.minor
76
- return False
77
-
78
- def __str__(self):
79
- return '{}.{}'.format(self.major, self.minor)
80
-
81
- @classmethod
82
- def parse(cls, string):
83
- """
84
- Parse a string to a MajorMinorPatch, or raise a ValueError.
85
- """
86
- string = drop_leading_v(string)
87
-
88
- match = re.match(r'^([0-9]+)\.([0-9]+)$', string)
89
-
90
- exception = ValueError('Unparsed: ' + string)
91
-
92
- if not match:
93
- raise exception
94
-
95
- identifiers = match.groups()
96
- if any([contains_leading_zeroes(identifier) for identifier in
97
- identifiers]):
98
- raise exception
99
-
100
- major = int(match.group(1))
101
- minor = int(match.group(2))
102
-
103
- return MajorMinor(major, minor)
104
-
105
-
106
- @total_ordering
107
- class MajorMinorPatch(MajorMinor):
108
- """
109
- A version number with major, minor, and patch components, e.g.
110
-
111
- 1.2.3
112
-
113
- """
114
- def __eq__(self, other):
115
- return (super(MajorMinorPatch, self).__eq__(other) and
116
- self.patch == other.patch)
117
-
118
- def __init__(self, major, minor, patch):
119
- super(MajorMinorPatch, self).__init__(major, minor)
120
- self.patch = patch
121
-
122
- def __le__(self, other):
123
- if super(MajorMinorPatch, self).__le__(other):
124
- if not super(MajorMinorPatch, self).__eq__(other):
125
- return True
126
- return self.patch <= other.patch
127
- return False
128
-
129
- def __str__(self):
130
- return '{}.{}'.format(super(MajorMinorPatch, self).__str__(),
131
- self.patch)
132
-
133
- @classmethod
134
- def parse(cls, string):
135
- """
136
- Parse a string to a MajorMinorPatch, or raise a ValueError.
137
- """
138
- string = drop_leading_v(string)
139
-
140
- (major, minor, patch, rest) = (
141
- parse_major_minor_patch(string))
142
-
143
- if rest:
144
- raise ValueError('Unparsed: ' + rest)
145
-
146
- return MajorMinorPatch(major, minor, patch)
147
-
148
-
149
- def lt_pre_release(self, other):
150
- """
151
- Check to see if one SemVer's pre_release version is less than that of
152
- another. From the SemVer spec:
153
-
154
- Pre-release versions have a lower precedence than the associated
155
- normal version.
156
-
157
- """
158
- if self.pre_release and other.pre_release:
159
- return self.pre_release < other.pre_release
160
- elif self.pre_release and not other.pre_release:
161
- return True
162
- return False
163
-
164
-
165
- def le_build_metadata(self, other):
166
- """
167
- Check to see if one SemVer's build_metadata is less than or equal to
168
- another. Like le_pre_release, this function gives versions with
169
- build_metadata a lower precedence than those without; however, it is
170
- unclear if this is useful and we may very well change it.
171
- """
172
- if self.build_metadata and other.build_metadata:
173
- return self.build_metadata <= other.build_metadata
174
- elif self.build_metadata and not other.build_metadata:
175
- return True
176
- return self.build_metadata == other.build_metadata
177
-
178
-
179
- @total_ordering
180
- class SemVer(MajorMinorPatch):
181
- """
182
- A Semantic Version (SemVer) number per the SemVer spec at
183
-
184
- <http://semver.org/>
185
-
186
- """
187
- def __eq__(self, other):
188
- return (super(SemVer, self).__eq__(other) and
189
- self.pre_release == other.pre_release and
190
- self.build_metadata == other.build_metadata)
191
-
192
- def __init__(self, major, minor, patch, pre_release=None,
193
- build_metadata=None):
194
- super(SemVer, self).__init__(major, minor, patch)
195
- self.pre_release = pre_release
196
- self.build_metadata = build_metadata
197
-
198
- def __le__(self, other):
199
- if super(SemVer, self).__le__(other):
200
- if type(self) is type(other):
201
- if not super(SemVer, self).__eq__(other):
202
- return True
203
- elif lt_pre_release(self, other):
204
- return True
205
- elif self.pre_release == other.pre_release:
206
- return le_build_metadata(self, other)
207
- return False
208
-
209
- def __str__(self):
210
- string = super(SemVer, self).__str__()
211
- if self.pre_release:
212
- string += '-' + self.pre_release
213
- if self.build_metadata:
214
- string += '+' + self.build_metadata
215
- return string
216
-
217
- @classmethod
218
- def parse(cls, string):
219
- """
220
- Parse a string to a SemVer, or raise a ValueError.
221
- """
222
- string = drop_leading_v(string)
223
-
224
- (major, minor, patch, rest) = (
225
- parse_major_minor_patch(string))
226
-
227
- # A pre-release version MAY be denoted by appending a hyphen and a
228
- # series of dot separated identifiers immediately following the patch
229
- # version.
230
- pre_release = None
231
- if rest and rest[0] == '-':
232
-
233
- match = re.match(r'-([0-9A-Za-z-.]+)', rest)
234
- if not match:
235
- raise ValueError(
236
- ('Identifiers MUST comprise only ASCII alphanumerics and '
237
- 'hyphen [0-9A-Za-z-]' + string))
238
-
239
- pre_release = match.group(1)
240
- identifiers = pre_release.split('.')
241
-
242
- if not all(identifiers):
243
- raise ValueError('Identifiers MUST NOT be empty: ' + string)
244
-
245
- if any([contains_leading_zeroes(identifier) for identifier in
246
- identifiers]):
247
- raise ValueError(
248
- 'Numeric identifiers MUST NOT include leading zeroes: ' +
249
- string)
250
-
251
- rest = rest[match.end():]
252
-
253
- # Build metadata MAY be denoted by appending a plus sign and a series
254
- # of dot separated identifiers immediately following the patch or
255
- # pre-release version.
256
- build_metadata = None
257
- if rest and rest[0] == '+':
258
-
259
- match = re.match(r'\+([0-9A-Za-z-.]+)$', rest)
260
- if not match:
261
- raise ValueError(
262
- ('Identifiers MUST comprise only ASCII alphanumerics and '
263
- 'hyphen [0-9A-Za-z-]: ' + string))
264
-
265
- build_metadata = match.group(1)
266
- identifiers = build_metadata.split('.')
267
-
268
- if not all(identifiers):
269
- return None
270
-
271
- rest = rest[match.end():]
272
-
273
- if rest:
274
- raise ValueError('Unparsed: ' + rest)
275
-
276
- return SemVer(major, minor, patch, pre_release, build_metadata)
277
-
278
-
279
- @total_ordering
280
- class TwilioVersion(MajorMinorPatch):
281
- """
282
- The Twilio version numbers we use have the form
283
-
284
- 1.2.3.b4-deadbee
285
-
286
- and they aren't quite SemVer. Essentially, we are tacking on build metadata
287
- with a "." instead of a "+", and in this build metadata we specify a build
288
- number and the git commit hash.
289
- """
290
- def __eq__(self, other):
291
- return (super(TwilioVersion, self).__eq__(other) and
292
- self.build_number == other.build_number and
293
- self.git_commit == other.git_commit)
294
-
295
- def __init__(self, major, minor, patch, git_commit, build_number=1):
296
- super(TwilioVersion, self).__init__(major, minor, patch)
297
- self.git_commit = git_commit
298
- self.build_number = build_number
299
-
300
- def __le__(self, other):
301
- if super(TwilioVersion, self).__le__(other):
302
- if type(self) is type(other):
303
- if not super(TwilioVersion, self).__eq__(other):
304
- return True
305
- elif self.build_number < other.build_number:
306
- return True
307
- elif self.build_number == other.build_number:
308
- return self.git_commit <= other.git_commit
309
- return False
310
-
311
- def __str__(self):
312
- return (super(TwilioVersion, self).__str__() +
313
- '.b{}-{}'.format(self.build_number, self.git_commit))
314
-
315
- @classmethod
316
- def parse(cls, string):
317
- """
318
- Parse a string to a TwilioVersion, or raise a ValueError.
319
- """
320
- string = drop_leading_v(string)
321
-
322
- (major, minor, patch, rest) = (
323
- parse_major_minor_patch(string))
324
-
325
- match = re.match(r'^\.b([0-9]+)-([a-z0-9]{7})$', rest)
326
- if not match:
327
- raise ValueError(
328
- 'Expecting build number and git commit: ' + string)
329
-
330
- build_number = match.group(1)
331
- git_commit = match.group(2)
332
- rest = rest[match.end():]
333
-
334
- if contains_leading_zeroes(build_number):
335
- raise ValueError('Build number contains leading zeroes: ' + string)
336
-
337
- build_number = int(build_number)
338
- if not build_number:
339
- raise ValueError('Build number must be non-zero: ' + string)
340
-
341
- if rest:
342
- raise ValueError('Unparsed: ' + rest)
343
-
344
- return TwilioVersion(major, minor, patch, git_commit, build_number)
345
-
346
-
347
- def parse_version(string):
348
- """
349
- Attempt to parse a string to a SemVer or TwilioVersion.
350
- """
351
- version_classes = [
352
- SemVer,
353
- TwilioVersion,
354
- ]
355
- for version_class in version_classes:
356
- try:
357
- return version_class.parse(string)
358
- except ValueError:
359
- pass
360
- raise ValueError('Input is neither a SemVer nor TwilioVersion: ' + string)
361
-
362
- parse_major_minor = MajorMinor.parse
@@ -1,28 +0,0 @@
1
- {
2
- "variables": {
3
- "platform": "js",
4
- "product_name": "conversations"
5
- },
6
- "public_dir": "sdk/{product_name}/",
7
- "release_dir": "sdk/{product_name}/{public_version}/{platform}/releases/",
8
- "schema": {
9
- "sdk": {
10
- "{product_name}": {
11
- "{public_version}": {
12
- "{platform}": {
13
- "docs": "releases/{release_version}/docs",
14
- "releases": {
15
- "{release_version}": {
16
- "docs/": null,
17
- "twilio-{product_name}.js": null,
18
- "twilio-{product_name}.min.js": null
19
- }
20
- },
21
- "twilio-{product_name}.js": "releases/{release_version}/twilio-{product_name}.js",
22
- "twilio-{product_name}.min.js": "releases/{release_version}/twilio-{product_name}.min.js"
23
- }
24
- }
25
- }
26
- }
27
- }
28
- }
@@ -1,94 +0,0 @@
1
- from random import shuffle
2
- from sdk_release_tools.versions import (MajorMinorPatch, SemVer, TwilioVersion,
3
- parse_version)
4
- import unittest
5
-
6
-
7
- class TestMajorMinorPatch(unittest.TestCase):
8
- version_class = MajorMinorPatch
9
-
10
- valid_sorted = [
11
- '0.0.1',
12
- '0.1.0',
13
- '1.0.0',
14
- '1.2.3',
15
- '1.2.30',
16
- '1.20.3',
17
- '10.2.3',
18
- ]
19
-
20
- invalid = [
21
- '',
22
- '1',
23
- '0.1',
24
- '01.2.3',
25
- '1.02.3',
26
- '1.2.03',
27
- 'x.y.z',
28
- ]
29
-
30
- def test_parse(self):
31
- for version in self.valid_sorted:
32
- assert self.version_class.parse(version)
33
- for version in self.invalid:
34
- with self.assertRaises(ValueError):
35
- self.version_class.parse(version)
36
-
37
- def test_str(self):
38
- for version in self.valid_sorted:
39
- assert str(self.version_class.parse(version)) == version
40
-
41
- def test_sort(self):
42
- shuffled_and_sorted = map(self.version_class.parse, self.valid_sorted)
43
- shuffle(shuffled_and_sorted)
44
- shuffled_and_sorted.sort()
45
- assert map(str, shuffled_and_sorted) == self.valid_sorted
46
-
47
-
48
- class TestSemVer(TestMajorMinorPatch):
49
- version_class = SemVer
50
-
51
- valid_sorted = [
52
- '0.1.0',
53
- '1.2.3-alpha',
54
- '1.2.3-beta',
55
- '1.2.3-dev+build',
56
- '1.2.3-dev',
57
- '1.2.3+build',
58
- '1.2.3',
59
- ]
60
-
61
- invalid = [
62
- '00.00.00',
63
- '01.2.3',
64
- '1.02.3',
65
- '1.2.03',
66
- 'x.y.z',
67
- ]
68
-
69
-
70
- class TestTwilioVersion(TestMajorMinorPatch):
71
- version_class = TwilioVersion
72
-
73
- valid_sorted = [
74
- '1.2.3.b1-deadbee',
75
- '1.2.3.b20-aaaaaaa',
76
- '1.2.3.b20-deadbee',
77
- ]
78
-
79
- invalid = [
80
- '1.2.3.b0-deadbee',
81
- '1.2.3.b1-deadbe',
82
- '1.2.3',
83
- '1.2.3-dev',
84
- '1.2.3-dev+build',
85
- '1.2.3+build',
86
- ]
87
-
88
-
89
- def test_parse_version():
90
- versions = (TestMajorMinorPatch.valid_sorted +
91
- TestSemVer.valid_sorted +
92
- TestTwilioVersion.valid_sorted)
93
- for version in versions:
94
- assert parse_version(version)