json-rest-api 1.0.22 → 1.0.24
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/CLAUDE.md +1 -2
- package/JSKIT_BACKEND_MIGRATION_TRACKER.txt +180 -0
- package/README.md +22 -1
- package/SINGLE_VALIDATION_CONTRACT_TODO.txt +172 -0
- package/docs/API.md +196 -38
- package/docs/COMPARISON.md +2 -2
- package/docs/GUIDE/GUIDE_1_Initial_Setup.md +111 -5
- package/docs/GUIDE/GUIDE_2_2_Manipulating_And_Searching_Tables.md +5 -1
- package/docs/GUIDE/GUIDE_2_7_Pagination_And_Ordering.md +3 -1
- package/docs/GUIDE/GUIDE_2_8_Effects_of_PUT_and_PATCH.md +12 -60
- package/docs/GUIDE/GUIDE_2_Data_And_Relations.md +2 -2
- package/docs/GUIDE/GUIDE_3_Field_Transformations.md +5 -1
- package/docs/GUIDE/GUIDE_7_Hooks_Data_Management_And_Plugins.md +2 -0
- package/docs/GUIDE/GUIDE_X_Autofiltering.md +355 -0
- package/docs/GUIDE/GUIDE_X_Fastify.md +78 -0
- package/docs/GUIDE/GUIDE_X_Knex_Schema_And_Migrations.md +370 -0
- package/docs/GUIDE/GUIDE_X_Query_Projections.md +159 -0
- package/docs/GUIDE/GUIDE_X_Writing_Plugins.md +199 -0
- package/docs/GUIDE/index.md +18 -9
- package/docs/QUICKSTART.md +5 -1
- package/docs/index.md +1 -1
- package/index.js +3 -2
- package/lib/enhanced-logger.js +1 -1
- package/package.json +6 -2
- package/plugins/core/bulk-operations-plugin.js +26 -34
- package/plugins/core/connectors/express-plugin.js +97 -190
- package/plugins/core/connectors/fastify-plugin.js +206 -0
- package/plugins/core/connectors/lib/busboy-detector.js +4 -4
- package/plugins/core/connectors/lib/connector-core.js +195 -0
- package/plugins/core/connectors/lib/transport-http-helpers.js +122 -0
- package/plugins/core/connectors/lib/transport-route-schemas.js +92 -0
- package/plugins/core/lib/anyapi/schema-utils.js +43 -4
- package/plugins/core/lib/anyapi/utils/descriptor-helpers.js +4 -1
- package/plugins/core/lib/dbIntrospection.js +1078 -0
- package/plugins/core/lib/dbTablesOperations.js +1111 -160
- package/plugins/core/lib/querying/knex-cross-table-search.js +0 -7
- package/plugins/core/lib/querying/knex-json-api-transformers-querying.js +5 -3
- package/plugins/core/lib/querying/knex-process-includes.js +3 -4
- package/plugins/core/lib/querying/knex-query-helpers.js +21 -76
- package/plugins/core/lib/querying/knex-relationship-includes.js +468 -215
- package/plugins/core/lib/querying/query-builder-utils.js +19 -0
- package/plugins/core/lib/querying/query-field-sort-helpers.js +135 -0
- package/plugins/core/lib/querying/sort-helpers.js +33 -0
- package/plugins/core/lib/querying/storage-adapter-utils.js +51 -0
- package/plugins/core/lib/querying/url-helpers.js +8 -2
- package/plugins/core/lib/querying-writing/compile-schemas.js +20 -5
- package/plugins/core/lib/querying-writing/knex-field-helpers.js +83 -14
- package/plugins/core/lib/querying-writing/knex-json-api-transformers.js +13 -12
- package/plugins/core/lib/querying-writing/query-field-helpers.js +88 -0
- package/plugins/core/lib/querying-writing/request-contracts.js +590 -0
- package/plugins/core/lib/querying-writing/resource-id-normalization.js +131 -0
- package/plugins/core/lib/querying-writing/schema-helpers.js +0 -2
- package/plugins/core/lib/querying-writing/simplified-helpers.js +4 -11
- package/plugins/core/lib/storage/canonical-storage-mapping.js +133 -0
- package/plugins/core/lib/storage/storage-adapter.js +82 -4
- package/plugins/core/lib/storage/storage-mapping.js +274 -0
- package/plugins/core/lib/writing/many-to-many-manipulations.js +4 -2
- package/plugins/core/rest-api-anyapi-knex-plugin.js +531 -312
- package/plugins/core/rest-api-autofilter-plugin.js +414 -0
- package/plugins/core/rest-api-knex-plugin.js +271 -226
- package/plugins/core/rest-api-plugin-hooks/register-relationship-routes.js +10 -5
- package/plugins/core/rest-api-plugin-hooks/register-scope-routes.js +12 -6
- package/plugins/core/rest-api-plugin-hooks/turn-scope-init-into-vars.js +1 -0
- package/plugins/core/rest-api-plugin-methods/apply-query-filters.js +41 -0
- package/plugins/core/rest-api-plugin-methods/common.js +148 -92
- package/plugins/core/rest-api-plugin-methods/delete-relationship.js +11 -2
- package/plugins/core/rest-api-plugin-methods/delete.js +6 -1
- package/plugins/core/rest-api-plugin-methods/enrich-attributes.js +6 -1
- package/plugins/core/rest-api-plugin-methods/get-related.js +7 -2
- package/plugins/core/rest-api-plugin-methods/get-relationship.js +7 -2
- package/plugins/core/rest-api-plugin-methods/get.js +29 -14
- package/plugins/core/rest-api-plugin-methods/patch-relationship.js +10 -3
- package/plugins/core/rest-api-plugin-methods/patch.js +56 -12
- package/plugins/core/rest-api-plugin-methods/post-relationship.js +11 -2
- package/plugins/core/rest-api-plugin-methods/post.js +21 -8
- package/plugins/core/rest-api-plugin-methods/put.js +73 -21
- package/plugins/core/rest-api-plugin-methods/query.js +15 -53
- package/plugins/core/rest-api-plugin-methods/release.js +0 -2
- package/plugins/core/rest-api-plugin.js +6 -0
- package/plugins/core/rest-api-positioning-plugin.js +2 -5
- package/plugins/core/rest-api-query-projections-plugin.js +130 -0
- package/plugins/core/socketio-plugin.js +1 -4
- package/plugins/storage/local-storage.js +1 -1
- package/plugins/storage/s3-storage.js +5 -2
- package/quickTest.js +1 -0
- package/scripts/run-docs.js +80 -84
- package/test-debug.js +1 -1
- package/tests/README.md +7 -0
- package/tests/anyapi-basic.test.js +3 -0
- package/tests/autofilter.test.js +463 -0
- package/tests/custom-id-mysql-returning-fallback.test.js +128 -0
- package/tests/custom-id-simplified-post.test.js +75 -0
- package/tests/custom-idproperty-relationships.test.js +33 -0
- package/tests/db-introspection.test.js +521 -0
- package/tests/db-table-operations.test.js +786 -0
- package/tests/fastify-plugin.test.js +156 -0
- package/tests/field-getters.test.js +1 -2
- package/tests/field-setters.test.js +0 -4
- package/tests/fixtures/api-configs.js +278 -176
- package/tests/helpers/fake-fastify.js +99 -0
- package/tests/http-connectors-parity.test.js +235 -0
- package/tests/id-normalization.test.js +444 -0
- package/tests/logical-id-write-validation.test.js +151 -0
- package/tests/pagination-cursor-multifield.test.js +11 -11
- package/tests/projected-fields.test.js +319 -0
- package/tests/relationships.test.js +3 -3
- package/tests/searchschema-knex-behavior.test.js +187 -0
- package/tests/searchschema-merge.test.js +21 -69
- package/tests/storage-mapping.test.js +259 -0
- package/audit/00-charter.md +0 -103
- package/audit/01-scope-map.md +0 -84
- package/audit/02-coverage-matrix.csv +0 -174
- package/audit/03-invariants.md +0 -123
- package/audit/04-standards-rubric.md +0 -56
- package/audit/05-competitor-rubric.md +0 -77
- package/audit/06-findings.md +0 -160
- package/audit/07-risk-register.csv +0 -10
- package/audit/08-remediation-roadmap.md +0 -177
- package/audit/09-signoff-check.md +0 -23
- package/audit/10-final-synthesis.md +0 -29
- package/audit/evidence/code/all-files-json-rest-api.txt +0 -168
- package/audit/evidence/code/all-files-json-rest-schema.txt +0 -12
- package/audit/evidence/code/boundary-leak-checks.txt +0 -72
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__bulk-operations-plugin.js.txt +0 -480
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__express-plugin.js.txt +0 -532
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__busboy-detector.js.txt +0 -175
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__formidable-detector.js.txt +0 -138
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__request-helpers.js.txt +0 -222
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__file-handling-plugin.js.txt +0 -342
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__dbTablesOperations.js.txt +0 -304
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__fractional-positioning.js.txt +0 -188
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__compile-schemas.js.txt +0 -336
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__connectors-query-parser.js.txt +0 -165
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__database-capabilities.js.txt +0 -265
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__database-value-normalizers.js.txt +0 -369
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__default-data-helpers.js.txt +0 -72
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__field-utils.js.txt +0 -139
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-constants.js.txt +0 -45
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-field-helpers.js.txt +0 -396
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-json-api-transformers.js.txt +0 -162
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__payload-validators.js.txt +0 -1314
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__schema-helpers.js.txt +0 -488
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__scope-validations.js.txt +0 -484
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__simplified-helpers.js.txt +0 -857
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-cross-table-search.js.txt +0 -565
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-json-api-transformers-querying.js.txt +0 -485
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-pagination-helpers.js.txt +0 -560
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-process-includes.js.txt +0 -167
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-query-helpers-base.js.txt +0 -109
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-query-helpers.js.txt +0 -1064
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-relationship-includes.js.txt +0 -1983
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-window-queries.js.txt +0 -328
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__url-helpers.js.txt +0 -119
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__storage__storage-adapter.js.txt +0 -160
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__writing__many-to-many-manipulations.js.txt +0 -300
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__writing__relationship-processor.js.txt +0 -245
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-access.js.txt +0 -459
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-cors-plugin.js.txt +0 -237
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-knex-plugin.js.txt +0 -1135
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-multihome-plugin.js.txt +0 -314
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__compile-resource-schemas.js.txt +0 -7
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__register-relationship-routes.js.txt +0 -71
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__register-scope-routes.js.txt +0 -102
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__turn-scope-init-into-vars.js.txt +0 -49
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__validate-include-configurations.js.txt +0 -39
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__add-route.js.txt +0 -23
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__check-permissions.js.txt +0 -13
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__common.js.txt +0 -639
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__delete-relationship.js.txt +0 -117
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__delete.js.txt +0 -104
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__enrich-attributes.js.txt +0 -199
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get-related.js.txt +0 -353
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get-relationship.js.txt +0 -61
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get.js.txt +0 -184
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__patch-relationship.js.txt +0 -55
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__patch.js.txt +0 -191
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__post-relationship.js.txt +0 -110
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__post.js.txt +0 -168
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__put.js.txt +0 -253
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__query.js.txt +0 -207
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__release.js.txt +0 -12
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin.js.txt +0 -165
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-positioning-plugin.js.txt +0 -668
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__socketio-plugin.js.txt +0 -621
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__storage__local-storage.js.txt +0 -218
- package/audit/evidence/code/critical-pass1/json-rest-api__plugins__storage__s3-storage.js.txt +0 -124
- package/audit/evidence/code/critical-pass1/json-rest-schema__src__CorePlugin.js.txt +0 -269
- package/audit/evidence/code/critical-pass1/json-rest-schema__src__Schema.js.txt +0 -242
- package/audit/evidence/code/critical-pass1/json-rest-schema__src__index.js.txt +0 -77
- package/audit/evidence/code/critical-pass1-risk-keywords.txt +0 -238
- package/audit/evidence/code/critical-pass1-summary.csv +0 -67
- package/audit/evidence/code/critical-pass2-summary.csv +0 -67
- package/audit/evidence/code/early-silent-zones-no-test-token.txt +0 -57
- package/audit/evidence/code/error-model-signals.txt +0 -98
- package/audit/evidence/code/git-files-json-rest-api.txt +0 -171
- package/audit/evidence/code/git-files-json-rest-schema.txt +0 -27
- package/audit/evidence/code/hook-flow-signals.txt +0 -282
- package/audit/evidence/code/idproperty-signals.txt +0 -157
- package/audit/evidence/code/import-cycles-non-anyapi.txt +0 -3
- package/audit/evidence/code/import-hotspots-non-anyapi.txt +0 -96
- package/audit/evidence/code/imports-json-rest-api.txt +0 -354
- package/audit/evidence/code/imports-json-rest-schema.txt +0 -15
- package/audit/evidence/code/in-scope-files-json-rest-api.txt +0 -160
- package/audit/evidence/code/in-scope-files-json-rest-schema.txt +0 -13
- package/audit/evidence/code/non-anyapi-core-files.txt +0 -101
- package/audit/evidence/code/permission-signals.txt +0 -193
- package/audit/evidence/code/query-include-signals.txt +0 -687
- package/audit/evidence/code/transaction-signals.txt +0 -28
- package/audit/evidence/code/validation-signals.txt +0 -650
- package/audit/evidence/code/write-path-signals.txt +0 -61
- package/audit/evidence/docs/docs-claims-signals.txt +0 -1075
- package/audit/evidence/docs/schema-docs-claims-signals.txt +0 -179
- package/audit/evidence/external/corpus-freeze.md +0 -21
- package/audit/evidence/external/npm-competitor-metadata.txt +0 -70
- package/audit/evidence/external/npm-download-signals.txt +0 -23
- package/audit/evidence/external/npm-jsonapi-server.txt +0 -8
- package/audit/evidence/external/npm-modern-jsonapi-metadata.txt +0 -38
- package/audit/evidence/external/readme-fortune-signals.txt +0 -26
- package/audit/evidence/external/readme-fortune.md +0 -165
- package/audit/evidence/external/readme-json-api-serializer-signals.txt +0 -80
- package/audit/evidence/external/readme-json-api-serializer.md +0 -690
- package/audit/evidence/external/readme-jsonapi-serde-server-signals.txt +0 -0
- package/audit/evidence/external/readme-jsonapi-serde-server.md +0 -22
- package/audit/evidence/external/readme-jsonapi-serializer-signals.txt +0 -63
- package/audit/evidence/external/readme-jsonapi-serializer.md +0 -315
- package/audit/evidence/external/readme-jsonapi-server-signals.txt +0 -19
- package/audit/evidence/external/readme-jsonapi-server.md +0 -104
- package/audit/evidence/external/readme-nestjs-json-api-signals.txt +0 -4
- package/audit/evidence/external/readme-nestjs-json-api.md +0 -94
- package/audit/evidence/external/readme-yaser-json-api-nestjs-signals.txt +0 -47
- package/audit/evidence/external/readme-yaser-json-api-nestjs.md +0 -447
- package/audit/evidence/external/standard-jsonapi-snippets.txt +0 -84
- package/audit/evidence/external/standard-rfc-snippets.txt +0 -168
- package/audit/evidence/external/standards-sources.txt +0 -6
- package/audit/evidence/runtime/baseline-commits.txt +0 -2
- package/audit/evidence/runtime/db-adapter-assumptions.txt +0 -3
- package/audit/evidence/runtime/environment.txt +0 -4
- package/audit/evidence/runtime/invariant-runtime-mapping.md +0 -38
- package/audit/evidence/runtime/probe-patch-relationship-error.exitcode +0 -1
- package/audit/evidence/runtime/probe-patch-relationship-error.log +0 -76
- package/audit/evidence/runtime/probe-patch-relationship-error.mjs +0 -67
- package/audit/evidence/runtime/probe-patch-relationship-referenceerror.exitcode +0 -1
- package/audit/evidence/runtime/probe-patch-relationship-referenceerror.log +0 -62
- package/audit/evidence/runtime/probe-patch-relationship-referenceerror.mjs +0 -47
- package/audit/evidence/runtime/test-exitcodes.txt +0 -4
- package/audit/evidence/runtime/test-summary.md +0 -107
- package/audit/evidence/runtime/trace-anchors.txt +0 -61
- package/audit/evidence/tests/access-multitenancy-test-signals.txt +0 -125
- package/audit/evidence/tests/failing-tests-summary.txt +0 -25
- package/audit/evidence/tests/npm-test-json-rest-api.exitcode +0 -1
- package/audit/evidence/tests/npm-test-json-rest-api.log +0 -5885
- package/audit/evidence/tests/npm-test-json-rest-schema.exitcode +0 -1
- package/audit/evidence/tests/npm-test-json-rest-schema.log +0 -356
- package/audit/evidence/tests/query-include-test-signals.txt +0 -948
- package/audit/evidence/tests/relationship-test-signals.txt +0 -223
- package/audit/evidence/tests/skipped-tests.txt +0 -10
- package/audit/evidence/tests/test-suite-list-non-anyapi.txt +0 -30
- package/audit/evidence/tests/test-suite-list.txt +0 -32
- package/audit/subsystems/docs-drift.md +0 -49
- package/audit/subsystems/pass2-cross-review.md +0 -131
- package/audit/subsystems/plugins-access.md +0 -51
- package/audit/subsystems/plugins-bulk.md +0 -50
- package/audit/subsystems/plugins-cors.md +0 -48
- package/audit/subsystems/plugins-file.md +0 -53
- package/audit/subsystems/plugins-multihome.md +0 -50
- package/audit/subsystems/plugins-positioning.md +0 -54
- package/audit/subsystems/plugins-socketio.md +0 -50
- package/audit/subsystems/query-engine.md +0 -61
- package/audit/subsystems/relationships.md +0 -55
- package/audit/subsystems/rest-orchestration.md +0 -66
- package/audit/subsystems/schema-core.md +0 -64
- package/audit/subsystems/storage-knex.md +0 -57
- package/audit/subsystems/tests.md +0 -48
- package/audit/subsystems/transport-express.md +0 -55
- package/audit/traces/trace-read-get.md +0 -22
- package/audit/traces/trace-read-query.md +0 -25
- package/audit/traces/trace-relationship-endpoints.md +0 -31
- package/audit/traces/trace-write-delete.md +0 -17
- package/audit/traces/trace-write-patch.md +0 -26
- package/audit/traces/trace-write-post.md +0 -22
- package/audit/traces/trace-write-put.md +0 -23
- package/docs/GUIDE/GUIDE_4_Authentication_And_Permissions.md +0 -707
- package/docs/GUIDE/GUIDE_X_Multihome.md +0 -666
- package/plugins/core/lib/querying-writing/payload-validators.js +0 -1314
- package/plugins/core/rest-api-access.js +0 -459
- package/plugins/core/rest-api-multihome-plugin.js +0 -314
- package/tests/multihome.test.js +0 -553
- package/tests/multihome.test.js.bak +0 -550
- package/tests/ownership-optout.test.js +0 -76
- package/tests/rest-api-access.test.js +0 -206
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
<p align='center'>
|
|
2
|
-
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/v/json-api-nestjs.svg" alt="NPM Version" /></a>
|
|
3
|
-
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/l/json-api-nestjs.svg" alt="Package License" /></a>
|
|
4
|
-
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/dm/json-api-nestjs.svg" alt="NPM Downloads" /></a>
|
|
5
|
-
<a href="http://commitizen.github.io/cz-cli/" target="_blank"><img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" /></a>
|
|
6
|
-
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/klerick/02a4c98cf7008fea2af70dc2d50f4cb7/raw/json-api-nestjs.json" alt="Coverage Badge" />
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
# json-api-nestjs
|
|
10
|
-
|
|
11
|
-
This plugin works upon **TypeOrm** or **MicroOrm** library, which is used as the main database abstraction layer tool. The module
|
|
12
|
-
automatically generates an API according to JSON API specification from the database structure (**TypeOrm** or **MicroOrm** entities). It
|
|
13
|
-
supports features such as requests validation based on database fields types, request filtering, endpoints extending,
|
|
14
|
-
data relations control and much more. Our module significantly reduces the development time of REST services by removing
|
|
15
|
-
the need to negotiate the mechanism of client-server interaction and implementing automatic API generation without the
|
|
16
|
-
need to write any code.
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
$ npm install @yaser2us/json-api-nestjs
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Example
|
|
25
|
-
|
|
26
|
-
Once the installation process is complete, we can import the **JsonApiModule** into the root **AppModule**.
|
|
27
|
-
### TypeOrm
|
|
28
|
-
```typescript
|
|
29
|
-
import {Module} from '@nestjs/common';
|
|
30
|
-
import {JsonApiModule} from '@yaser2us/json-api-nestjs';
|
|
31
|
-
import {TypeOrmJsonApiModule} from '@yaser2us/json-api-nestjs-typeorm';
|
|
32
|
-
import {Users} from 'type-orm/database';
|
|
33
|
-
|
|
34
|
-
@Module({
|
|
35
|
-
imports: [
|
|
36
|
-
JsonApiModule.forRoot(TypeOrmJsonApiModule, {
|
|
37
|
-
entities: [Users]
|
|
38
|
-
}),
|
|
39
|
-
],
|
|
40
|
-
})
|
|
41
|
-
export class AppModule {
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### MicroOrm
|
|
46
|
-
```typescript
|
|
47
|
-
import {Module} from '@nestjs/common';
|
|
48
|
-
import {JsonApiModule} from '@yaser2us/json-api-nestjs';
|
|
49
|
-
import {MicroOrmJsonApiModule} from '@yaser2us/json-api-nestjs-microorm';
|
|
50
|
-
import {Users} from 'micro-orm/database';
|
|
51
|
-
|
|
52
|
-
@Module({
|
|
53
|
-
imports: [
|
|
54
|
-
JsonApiModule.forRoot(MicroOrmJsonApiModule, {
|
|
55
|
-
entities: [Users]
|
|
56
|
-
}),
|
|
57
|
-
],
|
|
58
|
-
})
|
|
59
|
-
export class AppModule {
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
After this, you have to prepare CRUDs with ready-to-use endpoints:
|
|
64
|
-
|
|
65
|
-
- GET /users
|
|
66
|
-
- POST /users
|
|
67
|
-
- GET /users/:id
|
|
68
|
-
- PATCH /users/:id
|
|
69
|
-
- DELETE /users/:id
|
|
70
|
-
- GET /users/{id}/relationships/{relName}
|
|
71
|
-
- POST /users/{id}/relationships/{relName}
|
|
72
|
-
- PATCH /users/{id}/relationships/{relName}
|
|
73
|
-
- DELETE /users/{id}/relationships/{relName}
|
|
74
|
-
|
|
75
|
-
## Configuration params
|
|
76
|
-
|
|
77
|
-
The following interface is using for the configuration:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
export interface ModuleOptions {
|
|
81
|
-
entities: Entity[]; // List of typeOrm Entity
|
|
82
|
-
controllers?: NestController[]; // List of controller, if you need extend default present
|
|
83
|
-
connectionName?: string; // Type orm connection name: "default" is default name
|
|
84
|
-
providers?: NestProvider[]; // List of addition provider for useing in custom controller
|
|
85
|
-
imports?: NestImport[]; // List of addition module for useing in custom controller
|
|
86
|
-
options?: {
|
|
87
|
-
requiredSelectField?: boolean; // Need list of select field in get endpoint, try is default
|
|
88
|
-
debug?: boolean; // Debug info in result object, like error message
|
|
89
|
-
pipeForId?: Type<PipeTransform> // Nestjs pipe for validate id params, by default ParseIntPipe
|
|
90
|
-
operationUrl?: string // Url for atomic operation https://jsonapi.org/ext/atomic/
|
|
91
|
-
// You can add params for MicroOrm or TypeOrm adapter
|
|
92
|
-
} ;
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
You can extend the default controller:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
import {Get, Param, Inject, BadRequestException} from '@nestjs/common';
|
|
100
|
-
|
|
101
|
-
import {Users} from 'database';
|
|
102
|
-
import {
|
|
103
|
-
JsonApi,
|
|
104
|
-
excludeMethod,
|
|
105
|
-
JsonBaseController,
|
|
106
|
-
InjectService,
|
|
107
|
-
JsonApiService,
|
|
108
|
-
Query,
|
|
109
|
-
} from '@yaser2us/json-api-nestjs';
|
|
110
|
-
import {
|
|
111
|
-
ResourceObjectRelationships,
|
|
112
|
-
} from '@yaser2us/json-api-nestjs-shared';
|
|
113
|
-
import {ExampleService} from '../../service/example/example.service';
|
|
114
|
-
|
|
115
|
-
@JsonApi(Users, {
|
|
116
|
-
allowMethod: excludeMethod(['deleteRelationship']),
|
|
117
|
-
requiredSelectField: true,
|
|
118
|
-
overrideRoute: 'user',
|
|
119
|
-
})
|
|
120
|
-
export class ExtendUserController extends JsonBaseController<Users, 'id'> {
|
|
121
|
-
@InjectService() public service: JsonApiService<Users>;
|
|
122
|
-
@Inject(ExampleService) protected exampleService: ExampleService;
|
|
123
|
-
|
|
124
|
-
public override getAll(query: Query<Users, 'id'>): Promise<ResourceObject<Users, 'array'>> {
|
|
125
|
-
if (!this.exampleService.someCheck(query)) {
|
|
126
|
-
throw new BadRequestException({});
|
|
127
|
-
}
|
|
128
|
-
return this.service.getAll(query);// OR call parent method: super.getAll(query);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public override patchRelationship<Rel extends EntityRelation<Users>>(
|
|
132
|
-
id: string | number,
|
|
133
|
-
relName: Rel,
|
|
134
|
-
input: PatchRelationshipData
|
|
135
|
-
): Promise<ResourceObjectRelationships<Users, 'id', Rel>> {
|
|
136
|
-
return super.patchRelationship(id, relName, input);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
@Get(':id/example')
|
|
140
|
-
testOne(@Param('id') id: string): string {
|
|
141
|
-
return this.exampleService.testMethode(id);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
You can overwrite the default config for the current controller using options in the decorator **JsonAPi**.
|
|
147
|
-
Also you can specify an API method necessary for you, using **allowMethod**
|
|
148
|
-
Defulat validation check only simple type and database structure.
|
|
149
|
-
If you need custom pipe validation you can your owner pipe like this:
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
|
|
153
|
-
import { Query } from '@nestjs/common';
|
|
154
|
-
import {
|
|
155
|
-
JsonApi,
|
|
156
|
-
excludeMethod,
|
|
157
|
-
JsonBaseController,
|
|
158
|
-
InjectService,
|
|
159
|
-
JsonApiService,
|
|
160
|
-
Query as QueryType,
|
|
161
|
-
} from 'json-api-nestjs';
|
|
162
|
-
|
|
163
|
-
@JsonApi(Users, {
|
|
164
|
-
allowMethod: excludeMethod(['deleteRelationship']),
|
|
165
|
-
requiredSelectField: true,
|
|
166
|
-
overrideRoute: 'user',
|
|
167
|
-
})
|
|
168
|
-
export class ExtendUserController extends JsonBaseController<Users, 'id'> {
|
|
169
|
-
@InjectService() public service: JsonApiService<Users>;
|
|
170
|
-
@Inject(ExampleService) protected exampleService: ExampleService;
|
|
171
|
-
|
|
172
|
-
public override getAll(
|
|
173
|
-
@Query(ExamplePipe) query: QueryType<Users, 'id'>
|
|
174
|
-
): Promise<ResourceObject<Users, 'array'>> {
|
|
175
|
-
return super.getAll(query);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
import { ArgumentMetadata, PipeTransform } from '@nestjs/common';
|
|
182
|
-
|
|
183
|
-
import { Query } from 'json-api-nestjs';
|
|
184
|
-
import { Users } from 'database';
|
|
185
|
-
|
|
186
|
-
export class ExamplePipe implements PipeTransform<Query<Users, 'id'>, Query<Users, 'id'>> {
|
|
187
|
-
transform(value: Query<Users, 'id'>, metadata: ArgumentMetadata): Query<Users, 'id'> {
|
|
188
|
-
return value;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Swagger UI
|
|
194
|
-
|
|
195
|
-
For using swagger, you should only add [@nestjs/swagger](https://docs.nestjs.com/openapi/introduction) and configure it
|
|
196
|
-
```typescript
|
|
197
|
-
const app = await NestFactory.create(AppModule);
|
|
198
|
-
|
|
199
|
-
const config = new DocumentBuilder()
|
|
200
|
-
.setOpenAPIVersion('3.1.0')
|
|
201
|
-
.setTitle('JSON API swagger example')
|
|
202
|
-
.setDescription('The JSON API list example')
|
|
203
|
-
.setVersion('1.0')
|
|
204
|
-
.build();
|
|
205
|
-
|
|
206
|
-
SwaggerModule.setup(
|
|
207
|
-
'swagger',
|
|
208
|
-
app,
|
|
209
|
-
() => SwaggerModule.createDocument(app, config), // !!!Important: document as factory
|
|
210
|
-
{}
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Available endpoint method
|
|
216
|
-
|
|
217
|
-
Using **Users** entity and relation **Roles** entity as example
|
|
218
|
-
|
|
219
|
-
### List item of Users
|
|
220
|
-
|
|
221
|
-
```
|
|
222
|
-
GET /users
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
Available query params:
|
|
226
|
-
|
|
227
|
-
- **include** - you can extend result with relations (aka join)
|
|
228
|
-
```
|
|
229
|
-
GET /users?include=roles
|
|
230
|
-
```
|
|
231
|
-
result of request will have role relation for each **Users** item
|
|
232
|
-
|
|
233
|
-
- **fields** - you can specify required fields of result query
|
|
234
|
-
|
|
235
|
-
```
|
|
236
|
-
GET /users?fields[target]=login,lastName&fileds[roles]=name,key
|
|
237
|
-
```
|
|
238
|
-
The "target" is **Users** entity
|
|
239
|
-
The "roles" is **Roles** entity
|
|
240
|
-
So, result of request will be have only fields *login* and *lastName* for **Users** entity and fields *name* and *
|
|
241
|
-
key* for **Roles** entity
|
|
242
|
-
- **sort** - you can sort result of the request
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
GET /users?sort=target.name,-roles.key
|
|
246
|
-
```
|
|
247
|
-
The "target" is **Users** entity
|
|
248
|
-
The "roles" is **Roles** entity
|
|
249
|
-
So, result of the request will be sorted by field *name* of **Users** by *ASC* and field *key* of **Roles** entity
|
|
250
|
-
by **DESC**.
|
|
251
|
-
- **page** - pagination for you request
|
|
252
|
-
|
|
253
|
-
```
|
|
254
|
-
GET /users?page[number]=1page[size]=20
|
|
255
|
-
```
|
|
256
|
-
- **filter** - filter for query
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
GET /users?filter[name][eq]=1&filter[roles.name][ne]=test&filter[roles.status][eq]=true
|
|
260
|
-
```
|
|
261
|
-
The "name" is a field of **Users** entity
|
|
262
|
-
The "roles.name" is *name* field of **Roles** entity
|
|
263
|
-
The "eq", "ne" is *[Filter operand](#filter-operand)*
|
|
264
|
-
|
|
265
|
-
So, this query will be transformed like sql:
|
|
266
|
-
```sql
|
|
267
|
-
WHERE users.name = 1 AND roles.name <> 'test' AND roles.status = true
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
## Filter operand
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
type FilterOperand
|
|
274
|
-
{
|
|
275
|
-
in:string[] // is equal to the conditional of query "WHERE 'attribute_name' IN ('value1', 'value2')"
|
|
276
|
-
nin: string[] // is equal to the conditional of query "WHERE 'attribute_name' NOT IN ('value1', 'value1')"
|
|
277
|
-
eq: string // is equal to the conditional of query "WHERE 'attribute_name' = 'value1'
|
|
278
|
-
ne: string // is equal to the conditional of query "WHERE 'attribute_name' <> 'value1'
|
|
279
|
-
gte: string // is equal to the conditional of query "WHERE 'attribute_name' >= 'value1'
|
|
280
|
-
gt: string // is equal to the conditional of query "WHERE 'attribute_name' > 'value1'
|
|
281
|
-
lt: string // is equal to the conditional of query "WHERE 'attribute_name' < 'value1'
|
|
282
|
-
lte:string // is equal to the conditional of query "WHERE 'attribute_name' <= 'value1'
|
|
283
|
-
regexp: string // is equal to the conditional of query "WHERE 'attribute_name' ~* value1
|
|
284
|
-
some: string // is equal to the conditional of query "WHERE 'attribute_name' && [value1]
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### Get item of Users
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
GET /users/:id
|
|
292
|
-
```
|
|
293
|
-
- **include** - you can extend result with relations (aka join)
|
|
294
|
-
```
|
|
295
|
-
GET /users?include=roles
|
|
296
|
-
```
|
|
297
|
-
result of request will have role relation for each **Users** item
|
|
298
|
-
|
|
299
|
-
- **fields** - you can specify required fields of result query
|
|
300
|
-
|
|
301
|
-
```
|
|
302
|
-
GET /users?fields[target]=login,lastName&fileds[roles]=name,key
|
|
303
|
-
```
|
|
304
|
-
The "target" is **Users** entity
|
|
305
|
-
The "roles" is **Roles** entity
|
|
306
|
-
So, result of request will be have only fields *login* and *lastName* for **Users** entity and fields *name* and *
|
|
307
|
-
key* for **Roles** entity
|
|
308
|
-
|
|
309
|
-
### Create item of Users
|
|
310
|
-
```
|
|
311
|
-
POST /users
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
- **body** - Create new User and add link to address
|
|
315
|
-
|
|
316
|
-
```json
|
|
317
|
-
{
|
|
318
|
-
"data": {
|
|
319
|
-
"type": "users",
|
|
320
|
-
"attributes": {
|
|
321
|
-
"id": 0,
|
|
322
|
-
"login": "string",
|
|
323
|
-
"firstName": "string",
|
|
324
|
-
"lastName": "string",
|
|
325
|
-
"isActive": true,
|
|
326
|
-
"createdAt": "2023-12-08T10:32:27.352Z",
|
|
327
|
-
"updatedAt": "2023-12-08T10:32:27.352Z"
|
|
328
|
-
},
|
|
329
|
-
"relationships": {
|
|
330
|
-
"addresses": {
|
|
331
|
-
"id": "1",
|
|
332
|
-
"type": "addresses"
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
```
|
|
338
|
-
### Update item of Users
|
|
339
|
-
```
|
|
340
|
-
PATCH /users/:id
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
- **body** - Update User with id 1 and update link to address and manager
|
|
344
|
-
|
|
345
|
-
```json
|
|
346
|
-
{
|
|
347
|
-
"data": {
|
|
348
|
-
"id": "1",
|
|
349
|
-
"type": "users",
|
|
350
|
-
"attributes": {
|
|
351
|
-
"id": 0,
|
|
352
|
-
"login": "string",
|
|
353
|
-
"firstName": "string",
|
|
354
|
-
"lastName": "string",
|
|
355
|
-
"isActive": true,
|
|
356
|
-
"createdAt": "2023-12-08T10:34:57.752Z",
|
|
357
|
-
"updatedAt": "2023-12-08T10:34:57.752Z"
|
|
358
|
-
},
|
|
359
|
-
"relationships": {
|
|
360
|
-
"addresses": {
|
|
361
|
-
"id": "2",
|
|
362
|
-
"type": "addresses"
|
|
363
|
-
},
|
|
364
|
-
"manager": {
|
|
365
|
-
"id": "2",
|
|
366
|
-
"type": "users"
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### Atomic operation
|
|
375
|
-
You can more information find [here](https://jsonapi.org/ext/atomic/)
|
|
376
|
-
But you have additinal feature.
|
|
377
|
-
For example: you will need create new **Roles**, then - create new **Users** and assign new **Roles** to new **Users**.
|
|
378
|
-
If use native json api you need send 3 http request:
|
|
379
|
-
- POST /roles
|
|
380
|
-
- POST /users
|
|
381
|
-
|
|
382
|
-
but [Atomic operation](https://jsonapi.org/ext/atomic/) allow for one request.
|
|
383
|
-
```json
|
|
384
|
-
|
|
385
|
-
{
|
|
386
|
-
"atomic:operations":[
|
|
387
|
-
{
|
|
388
|
-
"op":"add",
|
|
389
|
-
"ref":{
|
|
390
|
-
"type":"roles",
|
|
391
|
-
"tmpId":10000
|
|
392
|
-
},
|
|
393
|
-
"data":{
|
|
394
|
-
"type":"roles",
|
|
395
|
-
"attributes":{
|
|
396
|
-
"name":"testRolesAgain",
|
|
397
|
-
"key":"testRolesAgain"
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
"op":"add",
|
|
403
|
-
"ref":{
|
|
404
|
-
"type":"users"
|
|
405
|
-
},
|
|
406
|
-
"data":{
|
|
407
|
-
"type":"users",
|
|
408
|
-
"attributes":{
|
|
409
|
-
"login":"newLogin"
|
|
410
|
-
},
|
|
411
|
-
"relationships":{
|
|
412
|
-
"addresses":{
|
|
413
|
-
"type":"addresses",
|
|
414
|
-
"id":"1"
|
|
415
|
-
},
|
|
416
|
-
"roles":[
|
|
417
|
-
{
|
|
418
|
-
"type":"roles",
|
|
419
|
-
"id":"10000"
|
|
420
|
-
}
|
|
421
|
-
]
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
]
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
```
|
|
429
|
-
**tmpId** - is params for operation **add**, should be unique for all operations.
|
|
430
|
-
|
|
431
|
-
If you have Interceptor you can check call it from **AtomicOperation**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
```ts
|
|
436
|
-
@Injectable()
|
|
437
|
-
export class AtomicInterceptor<T> implements NestInterceptor {
|
|
438
|
-
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<T> {
|
|
439
|
-
const isAtomic = context.getArgByIndex(3)
|
|
440
|
-
if (isAtomic) {
|
|
441
|
-
console.log('call from atomic operation')
|
|
442
|
-
}
|
|
443
|
-
return next.handle();
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
```
|
|
447
|
-
**isAtomic** - is array of params of method
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# JSON:API spec key clauses (captured)
|
|
2
|
-
captured_at=2026-03-01T16:01:55Z
|
|
3
|
-
source=https://jsonapi.org/format/
|
|
4
|
-
|
|
5
|
-
177:( application/vnd.api+json )
|
|
6
|
-
193: The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”,
|
|
7
|
-
194:“SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this
|
|
8
|
-
204: application/vnd.api+json .
|
|
9
|
-
236: The JSON:API media type MUST NOT be specified with any media type parameters
|
|
10
|
-
242:profile’s URI SHOULD return documentation that describes its usage. The
|
|
11
|
-
243:values of the ext and profile parameters MUST equal a space-separated
|
|
12
|
-
257: An extension MUST NOT lessen or remove any processing rules, restrictions or
|
|
13
|
-
268:extension MUST define a namespace to guarantee that extensions will never
|
|
14
|
-
270: MUST meet all of the following conditions:
|
|
15
|
-
273: A namespace MUST contain at least one character.
|
|
16
|
-
274: A namespace MUST contain only these characters:
|
|
17
|
-
283: An extension MUST NOT define more than one namespace. The namespace used for
|
|
18
|
-
284:all query parameters and document members MUST be the same for any given
|
|
19
|
-
292: Content-Type: application/vnd.api+json;ext= "https://jsonapi.org/ext/version"
|
|
20
|
-
314: A profile MUST NOT define any query parameters except implementation-specific query parameters .
|
|
21
|
-
316: A profile MUST NOT alter or remove processing rules that have been defined
|
|
22
|
-
322:parameter , but it could not specify that relationship
|
|
23
|
-
323:names in the include query parameter are
|
|
24
|
-
340: Content-Type: application/vnd.api+json;profile= "https://example.com/resource-timestamps"
|
|
25
|
-
361: Clients and servers MUST send all JSON:API payloads using the JSON:API media
|
|
26
|
-
364: Clients and servers MUST specify the ext media type parameter in the
|
|
27
|
-
368: Clients and servers MUST specify the profile media type parameters in the
|
|
28
|
-
374: When processing a JSON:API response document, clients MUST ignore any
|
|
29
|
-
399:servers MUST respond with a 415 Unsupported Media Type status code if
|
|
30
|
-
405:parameter contains an unsupported extension URI, the server MUST respond
|
|
31
|
-
415:servers MUST ignore instances of that media type which are modified by a
|
|
32
|
-
418:servers MUST respond with a 406 Not Acceptable status code. If every
|
|
33
|
-
420:at least one unsupported extension URI, the server MUST also respond with a
|
|
34
|
-
423: If the profile parameter is received, a server SHOULD attempt to apply any
|
|
35
|
-
424:requested profile(s) to its response. A server MUST ignore any profiles
|
|
36
|
-
433: Servers that support the ext or profile media type parameters SHOULD
|
|
37
|
-
453:members MUST comply with the naming requirements specified
|
|
38
|
-
457:extensions MUST NOT contain any additional members. Client and server
|
|
39
|
-
458:implementations MUST ignore non-compliant members.
|
|
40
|
-
467: A JSON object MUST be at the root of every JSON:API request and response
|
|
41
|
-
470: A document MUST contain at least one of the following top-level members:
|
|
42
|
-
474: errors : an array of error objects .
|
|
43
|
-
480: The members data and errors MUST NOT coexist in the same document.
|
|
44
|
-
487: included : an array of resource objects that are related to the primary
|
|
45
|
-
488:data and/or each other (“included resources”).
|
|
46
|
-
491: If a document does not contain a top-level data key, the included member
|
|
47
|
-
492: MUST NOT be present either.
|
|
48
|
-
498:document has extensions or profiles applied to it, this link SHOULD be
|
|
49
|
-
502:resource relationship.
|
|
50
|
-
513:by the client to generate the response document. This includes but is not
|
|
51
|
-
515: sparse fieldsets , sorting ,
|
|
52
|
-
522: Primary data MUST be either:
|
|
53
|
-
541: "relationships" : {
|
|
54
|
-
542: // ... this article's relationships
|
|
55
|
-
559: A logical collection of resources MUST be represented as an array, even if
|
|
56
|
-
566: A resource object MUST contain at least the following top-level members:
|
|
57
|
-
575:case, a client MAY include a lid member to uniquely identify the resource
|
|
58
|
-
582: relationships : a relationships object describing relationships between
|
|
59
|
-
586:resource that can not be represented as an attribute or relationship.
|
|
60
|
-
598: "relationships" : {
|
|
61
|
-
601: "self" : "/articles/1/relationships/author" ,
|
|
62
|
-
613: As noted above, every resource object MUST contain a
|
|
63
|
-
614: type member. Every resource object MUST also contain an id member,
|
|
64
|
-
617:a lid member MAY be included to uniquely identify the resource by type
|
|
65
|
-
618: locally within the document. The value of the lid member MUST be
|
|
66
|
-
622: The values of the id , type , and lid members MUST be strings.
|
|
67
|
-
624: Within a given API, each resource object’s type and id pair MUST
|
|
68
|
-
629:attributes and relationships.
|
|
69
|
-
631: The values of type members MUST adhere to the same constraints as
|
|
70
|
-
642: A resource object’s attributes and its relationships are collectively called
|
|
71
|
-
645: Fields for a resource object MUST share a common namespace with each
|
|
72
|
-
647:attribute and relationship with the same name, nor can it have an attribute
|
|
73
|
-
648:or relationship named type or id .
|
|
74
|
-
652: The value of the attributes key MUST be an object (an “attributes
|
|
75
|
-
659: Keys that reference related resources (e.g. author_id ) SHOULD NOT appear
|
|
76
|
-
660:as attributes. Instead, relationships SHOULD be used.
|
|
77
|
-
668: The value of the relationships key MUST be an object (a “relationships
|
|
78
|
-
669:object”). Each member of a relationships object represents
|
|
79
|
-
670:a “relationship” from the resource object
|
|
80
|
-
675: A relationship’s name is given by its key. The value at that key MUST be an
|
|
81
|
-
676:object (“relationship object”).
|
|
82
|
-
679:A “relationship object” MUST contain at least one of the following:
|
|
83
|
-
684: self : a link for the relationship itself (a “relationship link”). This
|
|
84
|
-
685:link allows the client to directly manipulate the relationship. For example,
|