@fc3/mmcadi 0.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/LICENSE +673 -0
- package/README.md +5 -0
- package/bin/compile +63 -0
- package/bin/copy-static-files +13 -0
- package/bin/install +5 -0
- package/bin/precompile +55 -0
- package/bin/prepublish +7 -0
- package/bin/remap-paths +113 -0
- package/bin/test +9 -0
- package/config/tsconfig.json +37 -0
- package/package.json +33 -0
- package/src/bootstrap/start.ts +12 -0
- package/src/client/bootstrap.ts +5 -0
- package/src/client/client.ts +54 -0
- package/src/client/enum/key-code.ts +34 -0
- package/src/client/enum/page-type.ts +19 -0
- package/src/client/factory/page.ts +61 -0
- package/src/client/page/confirm-delete-block.ts +30 -0
- package/src/client/page/create-block.ts +6 -0
- package/src/client/page/day.ts +8 -0
- package/src/client/page/edit-block.ts +43 -0
- package/src/client/page/edit-custom.ts +16 -0
- package/src/client/page/home.ts +8 -0
- package/src/client/page/login.ts +8 -0
- package/src/client/page/logout.ts +8 -0
- package/src/client/page/month.ts +8 -0
- package/src/client/page/move-block.ts +8 -0
- package/src/client/page/select-block-type.ts +56 -0
- package/src/client/page/settings.ts +8 -0
- package/src/client/page/view-custom.ts +665 -0
- package/src/client/page/week.ts +8 -0
- package/src/client/page/year.ts +8 -0
- package/src/client/page.ts +128 -0
- package/src/client/shim/execute.ts +5 -0
- package/src/client/shim/logger.ts +44 -0
- package/src/client/utility/get-meta-value.ts +23 -0
- package/src/common/builder/block/background.ts +25 -0
- package/src/common/builder/block/folder.ts +43 -0
- package/src/common/builder/block/header.ts +15 -0
- package/src/common/builder/block/link.ts +32 -0
- package/src/common/builder/block/multicolumn.ts +16 -0
- package/src/common/builder/block/note.ts +13 -0
- package/src/common/builder/block/whitespace.ts +13 -0
- package/src/common/utility/get-parent-path.ts +29 -0
- package/src/constant/month-names.ts +16 -0
- package/src/enum/action-type.ts +11 -0
- package/src/enum/block-type.ts +18 -0
- package/src/enum/calendar-view-mode.ts +9 -0
- package/src/enum/color.ts +15 -0
- package/src/enum/default-role.ts +6 -0
- package/src/enum/directory-item-type.ts +6 -0
- package/src/enum/emoji.ts +94 -0
- package/src/enum/field-type.ts +8 -0
- package/src/enum/header-size.ts +7 -0
- package/src/enum/permission-type.ts +8 -0
- package/src/enum/time-place-visibility.ts +8 -0
- package/src/enum/tool-type.ts +14 -0
- package/src/index.ts +8 -0
- package/src/interface/hydration-callback.ts +7 -0
- package/src/interface/provider.ts +8 -0
- package/src/interface/repository.ts +12 -0
- package/src/lib/array/add.ts +10 -0
- package/src/lib/array/assert-is-empty.ts +23 -0
- package/src/lib/array/clone.ts +5 -0
- package/src/lib/array/difference.ts +8 -0
- package/src/lib/array/empty.ts +6 -0
- package/src/lib/array/equal.ts +24 -0
- package/src/lib/array/get-first-value.ts +5 -0
- package/src/lib/array/get-last-value.ts +5 -0
- package/src/lib/array/get-max-value.ts +5 -0
- package/src/lib/array/get-value-after.ts +23 -0
- package/src/lib/array/get-value-before.ts +23 -0
- package/src/lib/array/get-values-between.ts +18 -0
- package/src/lib/array/index.ts +5 -0
- package/src/lib/array/is-empty.ts +6 -0
- package/src/lib/array/remove.ts +19 -0
- package/src/lib/array/sum.ts +11 -0
- package/src/lib/array/unique.ts +13 -0
- package/src/lib/environment/bootstrap.ts +1 -0
- package/src/lib/environment/enum/environment-type.ts +8 -0
- package/src/lib/environment/enum/service-type.ts +5 -0
- package/src/lib/environment/index.ts +7 -0
- package/src/lib/environment/utility/get-environment-type.ts +28 -0
- package/src/lib/environment/utility/is-browser.ts +5 -0
- package/src/lib/environment/utility/is-development.ts +10 -0
- package/src/lib/environment/utility/is-production-or-staging.ts +8 -0
- package/src/lib/environment/utility/is-production.ts +10 -0
- package/src/lib/environment/utility/is-staging.ts +10 -0
- package/src/lib/errors/enum/error-type.ts +13 -0
- package/src/lib/errors/error/base.ts +40 -0
- package/src/lib/errors/error/conflict.ts +16 -0
- package/src/lib/errors/error/generic.ts +23 -0
- package/src/lib/errors/error/invalid.ts +14 -0
- package/src/lib/errors/error/invariant-violation.ts +5 -0
- package/src/lib/errors/error/not-allowed.ts +14 -0
- package/src/lib/errors/error/not-found.ts +16 -0
- package/src/lib/errors/error/not-implemented.ts +20 -0
- package/src/lib/errors/error/omitted.ts +14 -0
- package/src/lib/errors/error/timeout.ts +14 -0
- package/src/lib/errors/error/unauthorized.ts +14 -0
- package/src/lib/errors/index.ts +18 -0
- package/src/lib/errors/sugar/invariant.ts +7 -0
- package/src/lib/errors/type/coded-error.ts +7 -0
- package/src/lib/errors/type/error-data.ts +11 -0
- package/src/lib/errors/utility/create-error-for-error-type.ts +60 -0
- package/src/lib/errors/utility/create-error-from-ambiguous-json-data.ts +26 -0
- package/src/lib/errors/utility/error-matches.ts +28 -0
- package/src/lib/errors/utility/get-error-type-for-posix-error-code.ts +37 -0
- package/src/lib/errors/utility/get-error-type-for-status-code.ts +38 -0
- package/src/lib/errors/utility/get-message-for-error-type.ts +29 -0
- package/src/lib/errors/utility/matches-posix-error-code.ts +11 -0
- package/src/lib/errors/utility/wrap-error.ts +39 -0
- package/src/lib/event-emitter/index.ts +63 -0
- package/src/lib/execution-context/execution-context.ts +90 -0
- package/src/lib/execution-context/index.ts +8 -0
- package/src/lib/execution-context/type/session.ts +7 -0
- package/src/lib/feature/feature.ts +108 -0
- package/src/lib/feature/index.ts +3 -0
- package/src/lib/filesystem/bootstrap.ts +1 -0
- package/src/lib/filesystem/enum/file-extension.ts +19 -0
- package/src/lib/filesystem/index.ts +4 -0
- package/src/lib/filesystem/utility/exists.ts +21 -0
- package/src/lib/filesystem/utility/get-extension-for-filepath.ts +20 -0
- package/src/lib/filesystem/utility/strip-extension.ts +26 -0
- package/src/lib/grammar/index.ts +3 -0
- package/src/lib/grammar/noun-inflector.ts +104 -0
- package/src/lib/grammar/utility/get-words-from-identifier.ts +9 -0
- package/src/lib/grammar/verb-inflector.ts +344 -0
- package/src/lib/http/buffer-stream.ts +76 -0
- package/src/lib/http/enum/content-type.ts +19 -0
- package/src/lib/http/enum/cookie-attribute.ts +11 -0
- package/src/lib/http/enum/header.ts +29 -0
- package/src/lib/http/enum/method.ts +11 -0
- package/src/lib/http/enum/same-site-policy.ts +7 -0
- package/src/lib/http/enum/status-code.ts +9 -0
- package/src/lib/http/factory/body-parser.ts +55 -0
- package/src/lib/http/index.ts +24 -0
- package/src/lib/http/interface/client-request.ts +15 -0
- package/src/lib/http/interface/incoming-message.ts +24 -0
- package/src/lib/http/interface/network-library.ts +9 -0
- package/src/lib/http/interface/request-callback.ts +7 -0
- package/src/lib/http/isomorphic/request.ts +77 -0
- package/src/lib/http/isomorphic/response.ts +77 -0
- package/src/lib/http/isomorphic.ts +20 -0
- package/src/lib/http/parser/accept-header.ts +35 -0
- package/src/lib/http/parser/basic-auth-header.ts +48 -0
- package/src/lib/http/parser/body/json.ts +14 -0
- package/src/lib/http/parser/body/multipart.ts +89 -0
- package/src/lib/http/parser/body/url-encoded.ts +16 -0
- package/src/lib/http/parser/body.ts +44 -0
- package/src/lib/http/parser/cookie.ts +114 -0
- package/src/lib/http/parser/querystring.ts +92 -0
- package/src/lib/http/parser/url.ts +76 -0
- package/src/lib/http/request/incoming.ts +299 -0
- package/src/lib/http/request/outgoing.ts +276 -0
- package/src/lib/http/request.ts +26 -0
- package/src/lib/http/response/incoming.ts +243 -0
- package/src/lib/http/response/outgoing.ts +160 -0
- package/src/lib/http/response.ts +74 -0
- package/src/lib/http/serializer/basic-auth-header.ts +27 -0
- package/src/lib/http/serializer/cookie.ts +90 -0
- package/src/lib/http/serializer/query-data.ts +54 -0
- package/src/lib/http/transaction.ts +320 -0
- package/src/lib/http/type/basic-auth-credentials.ts +6 -0
- package/src/lib/http/type/header-map.ts +5 -0
- package/src/lib/http/type/log-attributes.ts +12 -0
- package/src/lib/http/type/path-parameters.ts +5 -0
- package/src/lib/http/type/query-data.ts +7 -0
- package/src/lib/http/type/query-value.ts +11 -0
- package/src/lib/http/type/request-options.ts +16 -0
- package/src/lib/http/type/transaction-data.ts +4 -0
- package/src/lib/http/utility/get-content-type-for-extension.ts +47 -0
- package/src/lib/http/utility/get-library-for-protocol.ts +25 -0
- package/src/lib/http/utility/get-status-code-for-error-type.ts +37 -0
- package/src/lib/http/utility/get-status-code-for-error.ts +13 -0
- package/src/lib/http/utility/is-client-error-status.ts +15 -0
- package/src/lib/http/utility/is-error-status.ts +9 -0
- package/src/lib/http/utility/is-server-error-status.ts +7 -0
- package/src/lib/http/utility/is-success-status.ts +7 -0
- package/src/lib/http/utility/proxy-request.ts +58 -0
- package/src/lib/http/utility/serialize-request-options.ts +9 -0
- package/src/lib/http/utility/slug-generator.ts +20 -0
- package/src/lib/key-generator/index.ts +3 -0
- package/src/lib/key-generator/key-generator.ts +7 -0
- package/src/lib/logger/enum/ansi-escape-code.ts +14 -0
- package/src/lib/logger/enum/log-level.ts +8 -0
- package/src/lib/logger/formatter.ts +59 -0
- package/src/lib/logger/index.ts +7 -0
- package/src/lib/logger/interface/error-reporter.ts +7 -0
- package/src/lib/logger/interface/logger.ts +13 -0
- package/src/lib/logger/logger.ts +239 -0
- package/src/lib/logger/type/error-parameters.ts +9 -0
- package/src/lib/logger/type/loggable-data.ts +5 -0
- package/src/lib/logger/type/loggable-value.ts +1 -0
- package/src/lib/metrics/dispatcher.ts +264 -0
- package/src/lib/metrics/enum/dispatch-mode.ts +6 -0
- package/src/lib/metrics/index.ts +2 -0
- package/src/lib/metrics/settings-hydrator.ts +51 -0
- package/src/lib/metrics/type/dispatcher-settings.ts +12 -0
- package/src/lib/metrics/type/tag-map.ts +5 -0
- package/src/lib/network/bootstrap.ts +1 -0
- package/src/lib/network/enum/connection-status.ts +14 -0
- package/src/lib/network/enum/http-status-code.ts +75 -0
- package/src/lib/network/enum/network-protocol.ts +10 -0
- package/src/lib/network/event-emitter.ts +63 -0
- package/src/lib/network/index.ts +7 -0
- package/src/lib/network/interface/socket.ts +42 -0
- package/src/lib/network/type/socket-options.ts +6 -0
- package/src/lib/network/utility/get-protocol-from-url.ts +15 -0
- package/src/lib/operation/index.ts +6 -0
- package/src/lib/operation/operation/auto-logging.ts +94 -0
- package/src/lib/operation/operation/silent.ts +17 -0
- package/src/lib/operation/operation.ts +80 -0
- package/src/lib/process/bootstrap.ts +1 -0
- package/src/lib/process/enum/posix-error-code.ts +138 -0
- package/src/lib/process/enum/process-signal.ts +68 -0
- package/src/lib/process/error.ts +6 -0
- package/src/lib/process/execute.ts +77 -0
- package/src/lib/process/index.ts +4 -0
- package/src/lib/process/type/command-options.ts +9 -0
- package/src/lib/process/utility/bind-process-lifespan-to.ts +10 -0
- package/src/lib/promise-wrapper/index.ts +3 -0
- package/src/lib/promise-wrapper/promise-wrapper.ts +51 -0
- package/src/lib/random/chance.ts +5 -0
- package/src/lib/random/element.ts +7 -0
- package/src/lib/random/elements.ts +12 -0
- package/src/lib/random/enum.ts +34 -0
- package/src/lib/random/enums.ts +11 -0
- package/src/lib/random/index.ts +3 -0
- package/src/lib/random/number.ts +8 -0
- package/src/lib/server/base.ts +194 -0
- package/src/lib/server/enum/server-event.ts +5 -0
- package/src/lib/server/enum/server-status.ts +10 -0
- package/src/lib/server/http/endpoint/ping.ts +21 -0
- package/src/lib/server/http/endpoint.ts +345 -0
- package/src/lib/server/http/interface/endpoint-constructor.ts +12 -0
- package/src/lib/server/http/interface/result-serializer.ts +5 -0
- package/src/lib/server/http/middleware.ts +18 -0
- package/src/lib/server/http/result-serializer/html.ts +92 -0
- package/src/lib/server/http/result-serializer/json.ts +23 -0
- package/src/lib/server/http/route.ts +104 -0
- package/src/lib/server/http/router.ts +125 -0
- package/src/lib/server/http/type/session-resolver.ts +8 -0
- package/src/lib/server/http/utility/create-server.ts +34 -0
- package/src/lib/server/http/utility/path-parser.ts +49 -0
- package/src/lib/server/http/utility/standardize-html-indentation.ts +54 -0
- package/src/lib/server/http/websocket-wrapper.ts +83 -0
- package/src/lib/server/http.ts +301 -0
- package/src/lib/server/index.ts +5 -0
- package/src/lib/server/tcp.ts +53 -0
- package/src/lib/server/type/server-options.ts +10 -0
- package/src/lib/string/calculate-length.ts +17 -0
- package/src/lib/string/capitalize.ts +8 -0
- package/src/lib/string/create-slug.ts +14 -0
- package/src/lib/string/enum/ansi-escape-code.ts +14 -0
- package/src/lib/string/enum/string-encoding.ts +9 -0
- package/src/lib/string/hyphenate.ts +5 -0
- package/src/lib/string/index.ts +3 -0
- package/src/lib/string/pad.ts +14 -0
- package/src/lib/string/trim-multiline.ts +21 -0
- package/src/lib/string/trim.ts +8 -0
- package/src/lib/tcp/channel.ts +13 -0
- package/src/lib/tcp/connection/incoming.ts +72 -0
- package/src/lib/tcp/connection/outgoing.ts +219 -0
- package/src/lib/tcp/connection.ts +360 -0
- package/src/lib/tcp/enum/connection-event.ts +12 -0
- package/src/lib/tcp/enum/message-type.ts +9 -0
- package/src/lib/tcp/index.ts +1 -0
- package/src/lib/tcp/type/connection-parameters.ts +6 -0
- package/src/lib/tcp/type/message/channel-close.ts +9 -0
- package/src/lib/tcp/type/message/channel-open.ts +9 -0
- package/src/lib/tcp/type/message.ts +10 -0
- package/src/lib/test/index.ts +2 -0
- package/src/lib/test/utility/build-config.ts +17 -0
- package/src/lib/test/utility/build-execution-context.ts +11 -0
- package/src/lib/time/bootstrap.ts +1 -0
- package/src/lib/time/enum/time-interval.ts +12 -0
- package/src/lib/time/index.ts +4 -0
- package/src/lib/time/utility/format-duration.ts +139 -0
- package/src/lib/time/utility/format-relative-duration.ts +22 -0
- package/src/lib/time/utility/sleep.ts +9 -0
- package/src/operation.ts +18 -0
- package/src/server/endpoint/abstract-page.ts +126 -0
- package/src/server/endpoint/action/create.ts +545 -0
- package/src/server/endpoint/action/get.ts +231 -0
- package/src/server/endpoint/base.ts +51 -0
- package/src/server/endpoint/day.ts +13 -0
- package/src/server/endpoint/generic-page.ts +14 -0
- package/src/server/endpoint/index.ts +11 -0
- package/src/server/endpoint/login.ts +45 -0
- package/src/server/endpoint/logout.ts +38 -0
- package/src/server/endpoint/month.ts +35 -0
- package/src/server/endpoint/robots.ts +18 -0
- package/src/server/endpoint/session/create.ts +62 -0
- package/src/server/endpoint/settings/get.ts +40 -0
- package/src/server/endpoint/settings/update.ts +44 -0
- package/src/server/endpoint/today.ts +15 -0
- package/src/server/endpoint/week.ts +34 -0
- package/src/server/endpoint/year.ts +34 -0
- package/src/server/enum/custom-page-type.ts +10 -0
- package/src/server/factory/block-result-serializer.ts +115 -0
- package/src/server/middleware/base.ts +6 -0
- package/src/server/middleware/error-handler.ts +177 -0
- package/src/server/middleware/static-file.ts +83 -0
- package/src/server/operation/add-block.ts +110 -0
- package/src/server/operation/create-session.ts +43 -0
- package/src/server/operation/delete-block.ts +96 -0
- package/src/server/operation/demote-block.ts +108 -0
- package/src/server/operation/destroy-session.ts +26 -0
- package/src/server/operation/load-account.ts +30 -0
- package/src/server/operation/load-block.ts +48 -0
- package/src/server/operation/load-directory-items.ts +75 -0
- package/src/server/operation/load-page.ts +368 -0
- package/src/server/operation/promote-block.ts +104 -0
- package/src/server/operation/save-page.ts +60 -0
- package/src/server/operation/update-account-settings.ts +52 -0
- package/src/server/operation/update-block.ts +124 -0
- package/src/server/repository/memory.ts +112 -0
- package/src/server/result-serializer/action.ts +939 -0
- package/src/server/result-serializer/base.ts +1267 -0
- package/src/server/result-serializer/block/audio.ts +33 -0
- package/src/server/result-serializer/block/background.ts +20 -0
- package/src/server/result-serializer/block/calendar.ts +148 -0
- package/src/server/result-serializer/block/directory.ts +57 -0
- package/src/server/result-serializer/block/ephemeral.ts +14 -0
- package/src/server/result-serializer/block/folder.ts +106 -0
- package/src/server/result-serializer/block/header.ts +31 -0
- package/src/server/result-serializer/block/image.ts +46 -0
- package/src/server/result-serializer/block/link.ts +40 -0
- package/src/server/result-serializer/block/list.ts +140 -0
- package/src/server/result-serializer/block/multi-column.ts +97 -0
- package/src/server/result-serializer/block/note.ts +44 -0
- package/src/server/result-serializer/block/todo.ts +78 -0
- package/src/server/result-serializer/block/whitespace.ts +15 -0
- package/src/server/result-serializer/block.ts +248 -0
- package/src/server/result-serializer/common/time-place-options.ts +33 -0
- package/src/server/result-serializer/login.ts +58 -0
- package/src/server/result-serializer/month.ts +170 -0
- package/src/server/result-serializer/page.ts +548 -0
- package/src/server/result-serializer/settings.ts +85 -0
- package/src/server/result-serializer/week.ts +195 -0
- package/src/server/result-serializer/year.ts +160 -0
- package/src/server/utility/accepts-content-type.ts +16 -0
- package/src/server/utility/accepts-html.ts +9 -0
- package/src/server/utility/accepts-json.ts +9 -0
- package/src/server/utility/add-days.ts +11 -0
- package/src/server/utility/create-date.ts +23 -0
- package/src/server/utility/create-index-path.ts +5 -0
- package/src/server/utility/create-slug.ts +9 -0
- package/src/server/utility/create-toast-path.ts +19 -0
- package/src/server/utility/date-less-than.ts +5 -0
- package/src/server/utility/date-occurs-before.ts +22 -0
- package/src/server/utility/date-to-key.ts +7 -0
- package/src/server/utility/date-to-label.ts +5 -0
- package/src/server/utility/date-to-path.ts +9 -0
- package/src/server/utility/dates-are-equal.ts +22 -0
- package/src/server/utility/dates-are-in-order.ts +9 -0
- package/src/server/utility/dates-are-on-the-same-day.ts +9 -0
- package/src/server/utility/dates-in-same-month.ts +8 -0
- package/src/server/utility/day-to-date.ts +40 -0
- package/src/server/utility/decrement-date.ts +11 -0
- package/src/server/utility/get-block-at-index-path.ts +32 -0
- package/src/server/utility/get-block-permissions.ts +15 -0
- package/src/server/utility/get-compact-label-for-date.ts +8 -0
- package/src/server/utility/get-custom-page-type-for-path.ts +37 -0
- package/src/server/utility/get-element-id-for-block.ts +15 -0
- package/src/server/utility/get-emoji-for-block-type.ts +39 -0
- package/src/server/utility/get-emoji-for-tool-type.ts +20 -0
- package/src/server/utility/get-end-of-month.ts +13 -0
- package/src/server/utility/get-end-of-week.ts +13 -0
- package/src/server/utility/get-filepath-for-folder-block.ts +23 -0
- package/src/server/utility/get-hex-for-color.ts +31 -0
- package/src/server/utility/get-label-for-time-place-visibility.ts +23 -0
- package/src/server/utility/get-month-name.ts +18 -0
- package/src/server/utility/get-next-day.ts +7 -0
- package/src/server/utility/get-next-month.ts +12 -0
- package/src/server/utility/get-next-week.ts +12 -0
- package/src/server/utility/get-next-year.ts +13 -0
- package/src/server/utility/get-ordinal-label-for-week.ts +11 -0
- package/src/server/utility/get-ordinal-of-week-within-month.ts +15 -0
- package/src/server/utility/get-padded-date.ts +11 -0
- package/src/server/utility/get-parent-index-path.ts +18 -0
- package/src/server/utility/get-path-for-folder-block.ts +25 -0
- package/src/server/utility/get-path-from-url.ts +13 -0
- package/src/server/utility/get-previous-index-path.ts +27 -0
- package/src/server/utility/get-previous-month.ts +12 -0
- package/src/server/utility/get-previous-week.ts +11 -0
- package/src/server/utility/get-previous-year.ts +13 -0
- package/src/server/utility/get-random-emoji-for-date.ts +109 -0
- package/src/server/utility/get-short-label-for-date.ts +11 -0
- package/src/server/utility/get-short-month-name.ts +9 -0
- package/src/server/utility/get-short-ordinal.ts +26 -0
- package/src/server/utility/get-siblings-and-index-for-index-path.ts +67 -0
- package/src/server/utility/get-start-of-month.ts +11 -0
- package/src/server/utility/get-start-of-week.ts +12 -0
- package/src/server/utility/get-start-of-year.ts +12 -0
- package/src/server/utility/get-weekday-name.ts +24 -0
- package/src/server/utility/increment-date.ts +15 -0
- package/src/server/utility/is-index-path.ts +5 -0
- package/src/server/utility/key-to-date.ts +25 -0
- package/src/server/utility/month-has-week-containing-date.ts +13 -0
- package/src/server/utility/month-to-date.ts +28 -0
- package/src/server/utility/month-to-path.ts +10 -0
- package/src/server/utility/months-are-equal.ts +8 -0
- package/src/server/utility/parse-index-path.ts +23 -0
- package/src/server/utility/path-is-date.ts +13 -0
- package/src/server/utility/path-to-date.ts +24 -0
- package/src/server/utility/subtract-days.ts +7 -0
- package/src/server/utility/validate-month.ts +10 -0
- package/src/server/utility/validate-page.ts +46 -0
- package/src/server/utility/validate-path.ts +9 -0
- package/src/server/utility/validate-url.ts +12 -0
- package/src/server/utility/week-greater-than.ts +10 -0
- package/src/server/utility/week-to-date.ts +8 -0
- package/src/server/utility/week-to-path.ts +12 -0
- package/src/server/utility/weeks-are-equal.ts +8 -0
- package/src/server/utility/year-to-date.ts +26 -0
- package/src/server/utility/year-to-path.ts +7 -0
- package/src/server/utility/years-are-equal.ts +8 -0
- package/src/server.ts +140 -0
- package/src/test.ts +195 -0
- package/src/type/account-settings.ts +9 -0
- package/src/type/account.ts +11 -0
- package/src/type/action/add-block.ts +74 -0
- package/src/type/action/complete-block.ts +10 -0
- package/src/type/action/delete-block.ts +11 -0
- package/src/type/action/demote-block.ts +9 -0
- package/src/type/action/edit-block.ts +11 -0
- package/src/type/action/promote-block.ts +9 -0
- package/src/type/action.ts +9 -0
- package/src/type/block/audio.ts +8 -0
- package/src/type/block/background.ts +10 -0
- package/src/type/block/directory.ts +18 -0
- package/src/type/block/ephemeral.ts +9 -0
- package/src/type/block/folder.ts +14 -0
- package/src/type/block/header.ts +11 -0
- package/src/type/block/image.ts +8 -0
- package/src/type/block/link.ts +12 -0
- package/src/type/block/list.ts +24 -0
- package/src/type/block/multi-column.ts +10 -0
- package/src/type/block/note.ts +9 -0
- package/src/type/block/todo.ts +10 -0
- package/src/type/block/whitespace.ts +9 -0
- package/src/type/block-metadata.ts +14 -0
- package/src/type/block.ts +18 -0
- package/src/type/day.ts +5 -0
- package/src/type/field-definition.ts +8 -0
- package/src/type/field-value.ts +5 -0
- package/src/type/file.ts +6 -0
- package/src/type/month.ts +5 -0
- package/src/type/page.ts +8 -0
- package/src/type/price.ts +11 -0
- package/src/type/resource.ts +5 -0
- package/src/type/runtime-config.ts +13 -0
- package/src/type/server-settings.ts +17 -0
- package/src/type/toast.ts +8 -0
- package/src/type/week.ts +5 -0
- package/src/type/year.ts +5 -0
- package/test/unit/index.ts +11 -0
- package/test/unit/server/operation/promote-block.ts +84 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {GenericError} from 'lib/errors';
|
|
2
|
+
|
|
3
|
+
import isEmpty from 'lib/array/is-empty';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
function assertIsEmpty(array: any[], label?: string): void {
|
|
7
|
+
if (isEmpty(array)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const serialized_array = JSON.stringify(array);
|
|
12
|
+
|
|
13
|
+
if (label === undefined) {
|
|
14
|
+
label = 'array';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
throw new GenericError(`
|
|
18
|
+
Expected ${label} to be empty, but it had the following elements:
|
|
19
|
+
${serialized_array}
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default assertIsEmpty;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// TODO: should this be `unknown` instead of `any`?
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
+
function equal(array_a: any[], array_b: any[]): boolean {
|
|
4
|
+
if (array_a.length !== array_b.length) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let index = 0;
|
|
9
|
+
|
|
10
|
+
while (index < array_a.length) {
|
|
11
|
+
const array_a_value = array_a[index];
|
|
12
|
+
const array_b_value = array_b[index];
|
|
13
|
+
|
|
14
|
+
if (array_a_value !== array_b_value) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
index++;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default equal;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import getFirstValue from 'lib/array/get-first-value';
|
|
2
|
+
|
|
3
|
+
function getValueAfter<T>(array: T[], item: T, wrap = false): T | undefined {
|
|
4
|
+
let index = array.indexOf(item);
|
|
5
|
+
|
|
6
|
+
if (index === -1) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
index++;
|
|
11
|
+
|
|
12
|
+
if (index === array.length) {
|
|
13
|
+
if (wrap) {
|
|
14
|
+
return getFirstValue(array);
|
|
15
|
+
} else {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return array[index];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default getValueAfter;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import getLastValue from 'lib/array/get-last-value';
|
|
2
|
+
|
|
3
|
+
function getValueBefore<T>(array: T[], item: T, wrap = false): T | undefined {
|
|
4
|
+
let index = array.indexOf(item);
|
|
5
|
+
|
|
6
|
+
if (index === -1) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
index--;
|
|
11
|
+
|
|
12
|
+
if (index === -1) {
|
|
13
|
+
if (wrap) {
|
|
14
|
+
return getLastValue(array);
|
|
15
|
+
} else {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return array[index];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default getValueBefore;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {NotFoundError} from 'lib/errors';
|
|
2
|
+
|
|
3
|
+
function getValuesBetween<T>(array: T[], first_item: T, last_item: T): T[] {
|
|
4
|
+
const first_item_index = array.indexOf(first_item);
|
|
5
|
+
const last_item_index = array.indexOf(last_item);
|
|
6
|
+
|
|
7
|
+
if (first_item_index === -1) {
|
|
8
|
+
throw new NotFoundError(`Unable to find first item ${first_item} in array`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (last_item_index === -1) {
|
|
12
|
+
throw new NotFoundError(`Unable to find last item ${last_item} in array`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return array.slice(first_item_index, last_item_index + 1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default getValuesBetween;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export {default as clone} from 'lib/array/clone';
|
|
2
|
+
export {default as getLastValue} from 'lib/array/get-last-value';
|
|
3
|
+
export {default as getFirstValue} from 'lib/array/get-first-value';
|
|
4
|
+
export {default as getMaxValue} from 'lib/array/get-max-value';
|
|
5
|
+
export {default as equal} from 'lib/array/equal';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function remove<T>(array: T[], value: T): boolean {
|
|
2
|
+
let index = 0;
|
|
3
|
+
let hit = false;
|
|
4
|
+
|
|
5
|
+
while (index < array.length) {
|
|
6
|
+
const element = array[index];
|
|
7
|
+
|
|
8
|
+
if (element === value) {
|
|
9
|
+
array.splice(index, 1);
|
|
10
|
+
hit = true;
|
|
11
|
+
} else {
|
|
12
|
+
index++;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return hit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default remove;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
throw new Error('Not implemented');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export {default as EnvironmentType} from 'lib/environment/enum/environment-type';
|
|
2
|
+
export {default as ServiceType} from 'lib/environment/enum/service-type';
|
|
3
|
+
export {default as isProductionOrStaging} from 'lib/environment/utility/is-production-or-staging';
|
|
4
|
+
export {default as isProduction} from 'lib/environment/utility/is-production';
|
|
5
|
+
export {default as isDevelopment} from 'lib/environment/utility/is-development';
|
|
6
|
+
export {default as isBrowser} from 'lib/environment/utility/is-browser';
|
|
7
|
+
export {default as getEnvironmentType} from 'lib/environment/utility/get-environment-type';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import isBrowser from 'lib/environment/utility/is-browser';
|
|
2
|
+
import EnvironmentType from 'lib/environment/enum/environment-type';
|
|
3
|
+
|
|
4
|
+
function getEnvironmentType(): EnvironmentType {
|
|
5
|
+
if (isBrowser()) {
|
|
6
|
+
if (window.location.hostname.includes('saffron.gg')) {
|
|
7
|
+
return EnvironmentType.PRODUCTION;
|
|
8
|
+
} else {
|
|
9
|
+
return EnvironmentType.DEVELOPMENT;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
switch (process.env.NODE_ENV) {
|
|
14
|
+
case 'development':
|
|
15
|
+
case undefined:
|
|
16
|
+
return EnvironmentType.DEVELOPMENT;
|
|
17
|
+
case 'production':
|
|
18
|
+
return EnvironmentType.PRODUCTION;
|
|
19
|
+
case 'staging':
|
|
20
|
+
return EnvironmentType.STAGING;
|
|
21
|
+
case 'test':
|
|
22
|
+
return EnvironmentType.TEST;
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unsupported environment type: ${process.env.NODE_ENV}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default getEnvironmentType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import EnvironmentType from 'lib/environment/enum/environment-type';
|
|
2
|
+
import getEnvironmentType from 'lib/environment/utility/get-environment-type';
|
|
3
|
+
|
|
4
|
+
function isDevelopment(): boolean {
|
|
5
|
+
const environment_type = getEnvironmentType();
|
|
6
|
+
|
|
7
|
+
return environment_type === EnvironmentType.DEVELOPMENT;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default isDevelopment;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import EnvironmentType from 'lib/environment/enum/environment-type';
|
|
2
|
+
import getEnvironmentType from 'lib/environment/utility/get-environment-type';
|
|
3
|
+
|
|
4
|
+
function isProduction(): boolean {
|
|
5
|
+
const environment_type = getEnvironmentType();
|
|
6
|
+
|
|
7
|
+
return environment_type === EnvironmentType.PRODUCTION;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default isProduction;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import EnvironmentType from 'lib/environment/enum/environment-type';
|
|
2
|
+
import getEnvironmentType from 'lib/environment/utility/get-environment-type';
|
|
3
|
+
|
|
4
|
+
function isStaging(): boolean {
|
|
5
|
+
const environment_type = getEnvironmentType();
|
|
6
|
+
|
|
7
|
+
return environment_type === EnvironmentType.STAGING;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default isStaging;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
enum ErrorType {
|
|
2
|
+
CONFLICT = 'conflict',
|
|
3
|
+
GENERIC = 'generic',
|
|
4
|
+
OMITTED = 'omitted',
|
|
5
|
+
INVALID = 'invalid',
|
|
6
|
+
NOT_ALLOWED = 'not_allowed',
|
|
7
|
+
NOT_FOUND = 'not_found',
|
|
8
|
+
NOT_IMPLEMENTED = 'not_implemented',
|
|
9
|
+
TIMEOUT = 'timeout',
|
|
10
|
+
UNAUTHORIZED = 'unauthorized'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default ErrorType;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {PosixErrorCode} from 'lib/process';
|
|
2
|
+
|
|
3
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
4
|
+
import ErrorData from 'lib/errors/type/error-data';
|
|
5
|
+
|
|
6
|
+
abstract class BaseError extends Error {
|
|
7
|
+
public code: PosixErrorCode | null;
|
|
8
|
+
|
|
9
|
+
public constructor(message: string, code?: PosixErrorCode | null) {
|
|
10
|
+
message = message.replace(/\s+/g, ' ').trim();
|
|
11
|
+
|
|
12
|
+
super(message);
|
|
13
|
+
|
|
14
|
+
this.code = code || null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public getMessage(): string {
|
|
18
|
+
return this.message;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getCode(): PosixErrorCode | null {
|
|
22
|
+
return this.code;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public getData(): ErrorData {
|
|
26
|
+
const error_type = this.getType();
|
|
27
|
+
const code = this.getCode();
|
|
28
|
+
const message = this.getMessage();
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
error_type,
|
|
32
|
+
code,
|
|
33
|
+
message
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public abstract getType(): ErrorType;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default BaseError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {PosixErrorCode} from 'lib/process';
|
|
2
|
+
|
|
3
|
+
import BaseError from 'lib/errors/error/base';
|
|
4
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
5
|
+
|
|
6
|
+
class ConflictError extends BaseError {
|
|
7
|
+
public constructor(message?: string, code?: PosixErrorCode | null) {
|
|
8
|
+
super(message || 'Something went wrong', code);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public getType(): ErrorType {
|
|
12
|
+
return ErrorType.CONFLICT;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default ConflictError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {PosixErrorCode} from 'lib/process';
|
|
2
|
+
|
|
3
|
+
import BaseError from 'lib/errors/error/base';
|
|
4
|
+
import CodedError from 'lib/errors/type/coded-error';
|
|
5
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
6
|
+
|
|
7
|
+
class GenericError extends BaseError {
|
|
8
|
+
public static fromNativeError(error: Error): GenericError {
|
|
9
|
+
const coded_error = error as CodedError;
|
|
10
|
+
|
|
11
|
+
return new GenericError(coded_error.message, coded_error.code);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public constructor(message?: string, code?: PosixErrorCode | null) {
|
|
15
|
+
super(message || 'Something went wrong.', code);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public getType(): ErrorType {
|
|
19
|
+
return ErrorType.GENERIC;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default GenericError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BaseError from 'lib/errors/error/base';
|
|
2
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
3
|
+
|
|
4
|
+
class InvalidError extends BaseError {
|
|
5
|
+
public constructor(message?: string) {
|
|
6
|
+
super(message || 'The specified data is invalid.');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public getType(): ErrorType {
|
|
10
|
+
return ErrorType.INVALID;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default InvalidError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BaseError from 'lib/errors/error/base';
|
|
2
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
3
|
+
|
|
4
|
+
class NotAllowedError extends BaseError {
|
|
5
|
+
public constructor(message?: string) {
|
|
6
|
+
super(message || 'Not allowed');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public getType(): ErrorType {
|
|
10
|
+
return ErrorType.NOT_ALLOWED;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default NotAllowedError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {PosixErrorCode} from 'lib/process';
|
|
2
|
+
|
|
3
|
+
import BaseError from 'lib/errors/error/base';
|
|
4
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
5
|
+
|
|
6
|
+
class NotFoundError extends BaseError {
|
|
7
|
+
public constructor(message?: string, code?: PosixErrorCode | null) {
|
|
8
|
+
super(message || 'The desired file or resource was not found', code);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public getType(): ErrorType {
|
|
12
|
+
return ErrorType.NOT_FOUND;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default NotFoundError;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import BaseError from 'lib/errors/error/base';
|
|
2
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
3
|
+
|
|
4
|
+
class NotImplementedError extends BaseError {
|
|
5
|
+
public constructor(message?: string) {
|
|
6
|
+
if (message === undefined) {
|
|
7
|
+
message = 'Not implemented';
|
|
8
|
+
} else {
|
|
9
|
+
message = `Not implemented: ${message}`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
super(message);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public getType(): ErrorType {
|
|
16
|
+
return ErrorType.NOT_IMPLEMENTED;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default NotImplementedError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
2
|
+
import InvalidError from 'lib/errors/error/invalid';
|
|
3
|
+
|
|
4
|
+
class OmittedError extends InvalidError {
|
|
5
|
+
public constructor(message?: string) {
|
|
6
|
+
super(message || 'Must specify a value');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public getType(): ErrorType {
|
|
10
|
+
return ErrorType.OMITTED;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default OmittedError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BaseError from 'lib/errors/error/base';
|
|
2
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
3
|
+
|
|
4
|
+
class TimeoutError extends BaseError {
|
|
5
|
+
public constructor(message?: string) {
|
|
6
|
+
super(message || 'Operation timed out');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public getType(): ErrorType {
|
|
10
|
+
return ErrorType.TIMEOUT;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default TimeoutError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BaseError from 'lib/errors/error/base';
|
|
2
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
3
|
+
|
|
4
|
+
class UnauthorizedError extends BaseError {
|
|
5
|
+
public constructor(message?: string) {
|
|
6
|
+
super(message || 'Permission denied');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public getType(): ErrorType {
|
|
10
|
+
return ErrorType.UNAUTHORIZED;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default UnauthorizedError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {default as BaseError} from 'lib/errors/error/base';
|
|
2
|
+
export {default as ConflictError} from 'lib/errors/error/conflict';
|
|
3
|
+
export {default as GenericError} from 'lib/errors/error/generic';
|
|
4
|
+
export {default as InvalidError} from 'lib/errors/error/invalid';
|
|
5
|
+
export {default as NotFoundError} from 'lib/errors/error/not-found';
|
|
6
|
+
export {default as NotImplementedError} from 'lib/errors/error/not-implemented';
|
|
7
|
+
export {default as TimeoutError} from 'lib/errors/error/timeout';
|
|
8
|
+
export {default as UnauthorizedError} from 'lib/errors/error/unauthorized';
|
|
9
|
+
export {default as InvariantViolation} from 'lib/errors/error/invariant-violation';
|
|
10
|
+
|
|
11
|
+
export {default as wrapError} from 'lib/errors/utility/wrap-error';
|
|
12
|
+
export {default as ErrorType} from 'lib/errors/enum/error-type';
|
|
13
|
+
export {default as createErrorFromAmbiguousJsonData} from 'lib/errors/utility/create-error-from-ambiguous-json-data';
|
|
14
|
+
export {default as matchesPosixErrorCode} from 'lib/errors/utility/matches-posix-error-code';
|
|
15
|
+
export {default as getErrorTypeForStatusCode} from 'lib/errors/utility/get-error-type-for-status-code';
|
|
16
|
+
export {default as createErrorForErrorType} from 'lib/errors/utility/create-error-for-error-type';
|
|
17
|
+
|
|
18
|
+
export {default as invariant} from 'lib/errors/sugar/invariant';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {PosixErrorCode} from 'lib/process';
|
|
2
|
+
|
|
3
|
+
import ErrorType from 'lib/errors/enum/error-type';
|
|
4
|
+
|
|
5
|
+
interface ErrorData {
|
|
6
|
+
readonly error_type: ErrorType;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
readonly code: PosixErrorCode | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default ErrorData;
|