@undefineds.co/xpod 0.1.7 → 0.2.0-preview.2
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/README.md +141 -2
- package/config/cli.json +9 -71
- package/config/cloud.json +34 -7
- package/config/local.json +6 -2
- package/config/resolver.json +11 -49
- package/config/runtime-open.json +22 -0
- package/config/xpod.base.json +32 -0
- package/config/xpod.cluster.json +2 -44
- package/config/xpod.json +5 -2
- package/dist/api/auth/AuthContext.d.ts +12 -1
- package/dist/api/auth/AuthContext.js +18 -1
- package/dist/api/auth/AuthContext.js.map +1 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +0 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
- package/dist/api/auth/ServiceTokenAuthenticator.d.ts +18 -0
- package/dist/api/auth/ServiceTokenAuthenticator.js +50 -0
- package/dist/api/auth/ServiceTokenAuthenticator.js.map +1 -0
- package/dist/api/auth/index.d.ts +1 -0
- package/dist/api/auth/index.js +1 -0
- package/dist/api/auth/index.js.map +1 -1
- package/dist/api/chatkit/ai-provider.d.ts +0 -10
- package/dist/api/chatkit/ai-provider.js +11 -120
- package/dist/api/chatkit/ai-provider.js.map +1 -1
- package/dist/api/chatkit/default-agent.js +11 -8
- package/dist/api/chatkit/default-agent.js.map +1 -1
- package/dist/api/chatkit/pod-store.js +19 -3
- package/dist/api/chatkit/pod-store.js.map +1 -1
- package/dist/api/chatkit/schema.d.ts +9 -3
- package/dist/api/chatkit/schema.js +14 -6
- package/dist/api/chatkit/schema.js.map +1 -1
- package/dist/api/container/business-token.d.ts +9 -0
- package/dist/api/container/business-token.js +32 -0
- package/dist/api/container/business-token.js.map +1 -0
- package/dist/api/container/cloud.js +36 -12
- package/dist/api/container/cloud.js.map +1 -1
- package/dist/api/container/common.js +12 -5
- package/dist/api/container/common.js.map +1 -1
- package/dist/api/container/index.js +94 -14
- package/dist/api/container/index.js.map +1 -1
- package/dist/api/container/local.js +2 -1
- package/dist/api/container/local.js.map +1 -1
- package/dist/api/container/routes.js +81 -9
- package/dist/api/container/routes.js.map +1 -1
- package/dist/api/container/types.d.ts +8 -6
- package/dist/api/container/types.js.map +1 -1
- package/dist/api/handlers/AdminHandler.js +9 -9
- package/dist/api/handlers/AdminHandler.js.map +1 -1
- package/dist/api/handlers/ApiKeyHandler.js +0 -6
- package/dist/api/handlers/ApiKeyHandler.js.map +1 -1
- package/dist/api/handlers/EdgeNodeSignalHandler.d.ts +17 -0
- package/dist/api/handlers/EdgeNodeSignalHandler.js +171 -0
- package/dist/api/handlers/EdgeNodeSignalHandler.js.map +1 -0
- package/dist/api/handlers/PodManagementHandler.d.ts +5 -4
- package/dist/api/handlers/PodManagementHandler.js +11 -10
- package/dist/api/handlers/PodManagementHandler.js.map +1 -1
- package/dist/api/handlers/ProvisionHandler.d.ts +42 -0
- package/dist/api/handlers/ProvisionHandler.js +161 -0
- package/dist/api/handlers/ProvisionHandler.js.map +1 -0
- package/dist/api/handlers/QuotaHandler.d.ts +7 -7
- package/dist/api/handlers/QuotaHandler.js +143 -73
- package/dist/api/handlers/QuotaHandler.js.map +1 -1
- package/dist/api/handlers/SubdomainClientHandler.js +2 -2
- package/dist/api/handlers/SubdomainClientHandler.js.map +1 -1
- package/dist/api/handlers/SubdomainHandler.js +13 -8
- package/dist/api/handlers/SubdomainHandler.js.map +1 -1
- package/dist/api/handlers/UsageHandler.d.ts +14 -0
- package/dist/api/handlers/UsageHandler.js +123 -0
- package/dist/api/handlers/UsageHandler.js.map +1 -0
- package/dist/api/handlers/index.d.ts +3 -1
- package/dist/api/handlers/index.js +3 -1
- package/dist/api/handlers/index.js.map +1 -1
- package/dist/api/main.js +18 -0
- package/dist/api/main.js.map +1 -1
- package/dist/api/middleware/OpenAuthMiddleware.d.ts +12 -0
- package/dist/api/middleware/OpenAuthMiddleware.js +27 -0
- package/dist/api/middleware/OpenAuthMiddleware.js.map +1 -0
- package/dist/api/runtime.d.ts +15 -0
- package/dist/api/runtime.js +104 -0
- package/dist/api/runtime.js.map +1 -0
- package/dist/api/service/VercelChatService.d.ts +16 -7
- package/dist/api/service/VercelChatService.js +98 -178
- package/dist/api/service/VercelChatService.js.map +1 -1
- package/dist/api/store/DrizzleClientCredentialsStore.d.ts +6 -11
- package/dist/api/store/DrizzleClientCredentialsStore.js +9 -39
- package/dist/api/store/DrizzleClientCredentialsStore.js.map +1 -1
- package/dist/authorization/AuthModeSelector.d.ts +10 -0
- package/dist/authorization/AuthModeSelector.js +27 -0
- package/dist/authorization/AuthModeSelector.js.map +1 -0
- package/dist/authorization/AuthModeSelector.jsonld +81 -0
- package/dist/cli/commands/account.d.ts +6 -0
- package/dist/cli/commands/account.js +119 -0
- package/dist/cli/commands/account.js.map +1 -0
- package/dist/cli/commands/auth.js +20 -29
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/backup.d.ts +15 -0
- package/dist/cli/commands/backup.js +286 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/config.d.ts +34 -3
- package/dist/cli/commands/config.js +195 -258
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +6 -0
- package/dist/cli/commands/doctor.js +94 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/pod.d.ts +6 -0
- package/dist/cli/commands/pod.js +124 -0
- package/dist/cli/commands/pod.js.map +1 -0
- package/dist/cli/commands/start.js +28 -5
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/index.js +9 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lib/credentials-store.d.ts +17 -0
- package/dist/cli/lib/credentials-store.js +73 -0
- package/dist/cli/lib/credentials-store.js.map +1 -0
- package/dist/cli/lib/css-account.d.ts +17 -0
- package/dist/cli/lib/css-account.js +56 -0
- package/dist/cli/lib/css-account.js.map +1 -1
- package/dist/cli/lib/pod-thread-store.d.ts +57 -0
- package/dist/cli/lib/pod-thread-store.js +310 -0
- package/dist/cli/lib/pod-thread-store.js.map +1 -0
- package/dist/cli/lib/solid-auth.d.ts +20 -0
- package/dist/cli/lib/solid-auth.js +70 -0
- package/dist/cli/lib/solid-auth.js.map +1 -0
- package/dist/components/components.jsonld +5 -8
- package/dist/components/context.jsonld +114 -244
- package/dist/edge/EdgeNodeAgent.js +2 -2
- package/dist/edge/EdgeNodeAgent.js.map +1 -1
- package/dist/edge/EdgeNodeDnsCoordinator.d.ts +1 -7
- package/dist/edge/EdgeNodeDnsCoordinator.js +31 -41
- package/dist/edge/EdgeNodeDnsCoordinator.js.map +1 -1
- package/dist/edge/EdgeNodeDnsCoordinator.jsonld +1 -27
- package/dist/edge/EdgeNodeModeDetector.d.ts +1 -1
- package/dist/edge/EdgeNodeModeDetector.js +9 -11
- package/dist/edge/EdgeNodeModeDetector.js.map +1 -1
- package/dist/http/ClusterIngressRouter.js +3 -3
- package/dist/http/ClusterIngressRouter.js.map +1 -1
- package/dist/http/ClusterWebSocketConfigurator.js +2 -2
- package/dist/http/ClusterWebSocketConfigurator.js.map +1 -1
- package/dist/http/PodRoutingHttpHandler.js +2 -2
- package/dist/http/PodRoutingHttpHandler.js.map +1 -1
- package/dist/http/cluster/PodMigrationHttpHandler.d.ts +1 -1
- package/dist/http/cluster/PodMigrationHttpHandler.js +1 -1
- package/dist/http/cluster/PodMigrationHttpHandler.js.map +1 -1
- package/dist/identity/drizzle/EdgeNodeRepository.d.ts +37 -4
- package/dist/identity/drizzle/EdgeNodeRepository.js +120 -128
- package/dist/identity/drizzle/EdgeNodeRepository.js.map +1 -1
- package/dist/identity/drizzle/ServiceTokenRepository.d.ts +52 -0
- package/dist/identity/drizzle/ServiceTokenRepository.js +143 -0
- package/dist/identity/drizzle/ServiceTokenRepository.js.map +1 -0
- package/dist/identity/drizzle/db.d.ts +9 -0
- package/dist/identity/drizzle/db.js +208 -1
- package/dist/identity/drizzle/db.js.map +1 -1
- package/dist/identity/drizzle/schema.pg.d.ts +5 -0
- package/dist/identity/drizzle/schema.pg.js +49 -20
- package/dist/identity/drizzle/schema.pg.js.map +1 -1
- package/dist/identity/drizzle/schema.sqlite.d.ts +332 -57
- package/dist/identity/drizzle/schema.sqlite.js +48 -18
- package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
- package/dist/identity/oidc/AutoDetectIdentityProviderHandler.js +6 -4
- package/dist/identity/oidc/AutoDetectIdentityProviderHandler.js.map +1 -1
- package/dist/index.d.ts +6 -9
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/dist/main.js +25 -8
- package/dist/main.js.map +1 -1
- package/dist/provision/ProvisionCodeCodec.d.ts +39 -0
- package/dist/provision/ProvisionCodeCodec.js +65 -0
- package/dist/provision/ProvisionCodeCodec.js.map +1 -0
- package/dist/provision/ProvisionCodeCodec.jsonld +47 -0
- package/dist/provision/ProvisionPodCreator.d.ts +20 -0
- package/dist/provision/ProvisionPodCreator.js +84 -0
- package/dist/provision/ProvisionPodCreator.js.map +1 -0
- package/dist/provision/ProvisionPodCreator.jsonld +118 -0
- package/dist/quota/DrizzleQuotaService.d.ts +17 -3
- package/dist/quota/DrizzleQuotaService.js +108 -8
- package/dist/quota/DrizzleQuotaService.js.map +1 -1
- package/dist/quota/DrizzleQuotaService.jsonld +33 -22
- package/dist/quota/NoopQuotaService.d.ts +7 -1
- package/dist/quota/NoopQuotaService.js +12 -0
- package/dist/quota/NoopQuotaService.js.map +1 -1
- package/dist/quota/NoopQuotaService.jsonld +24 -0
- package/dist/quota/QuotaService.d.ts +17 -0
- package/dist/quota/QuotaService.js +5 -0
- package/dist/quota/QuotaService.js.map +1 -1
- package/dist/quota/QuotaService.jsonld +50 -0
- package/dist/runtime/Proxy.d.ts +22 -4
- package/dist/runtime/Proxy.js +154 -35
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/runtime/XpodRuntime.d.ts +49 -0
- package/dist/runtime/XpodRuntime.js +374 -0
- package/dist/runtime/XpodRuntime.js.map +1 -0
- package/dist/runtime/env-utils.d.ts +2 -0
- package/dist/runtime/env-utils.js +55 -0
- package/dist/runtime/env-utils.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +8 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/socket-fetch.d.ts +1 -0
- package/dist/runtime/socket-fetch.js +72 -0
- package/dist/runtime/socket-fetch.js.map +1 -0
- package/dist/runtime/socket-http.d.ts +1 -0
- package/dist/runtime/socket-http.js +142 -0
- package/dist/runtime/socket-http.js.map +1 -0
- package/dist/runtime/socket-utils.d.ts +2 -0
- package/dist/runtime/socket-utils.js +34 -0
- package/dist/runtime/socket-utils.js.map +1 -0
- package/dist/service/{EdgeNodeHeartbeatService.d.ts → EdgeNodeSignalClient.d.ts} +3 -3
- package/dist/service/{EdgeNodeHeartbeatService.js → EdgeNodeSignalClient.js} +4 -4
- package/dist/service/EdgeNodeSignalClient.js.map +1 -0
- package/dist/service/PodMigrationService.d.ts +1 -2
- package/dist/service/PodMigrationService.js +1 -2
- package/dist/service/PodMigrationService.js.map +1 -1
- package/dist/storage/SparqlUpdateResourceStore.js +1 -1
- package/dist/storage/SparqlUpdateResourceStore.js.map +1 -1
- package/dist/storage/accessors/MinioDataAccessor.d.ts +6 -0
- package/dist/storage/accessors/MinioDataAccessor.js +10 -0
- package/dist/storage/accessors/MinioDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MinioDataAccessor.jsonld +4 -0
- package/dist/storage/accessors/MixDataAccessor.d.ts +2 -1
- package/dist/storage/accessors/MixDataAccessor.js +12 -1
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +19 -0
- package/dist/storage/locking/UrlAwareRedisLocker.d.ts +18 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js +60 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js.map +1 -0
- package/dist/storage/locking/UrlAwareRedisLocker.jsonld +123 -0
- package/dist/storage/quota/UsageRepository.d.ts +41 -8
- package/dist/storage/quota/UsageRepository.js +252 -50
- package/dist/storage/quota/UsageRepository.js.map +1 -1
- package/dist/storage/sparql/ComunicaQuintEngine.d.ts +9 -0
- package/dist/storage/sparql/ComunicaQuintEngine.js +50 -9
- package/dist/storage/sparql/ComunicaQuintEngine.js.map +1 -1
- package/dist/storage/sparql/QueryOptimizer.js +13 -1
- package/dist/storage/sparql/QueryOptimizer.js.map +1 -1
- package/dist/storage/sparql/QuintQuerySource.d.ts +14 -0
- package/dist/storage/sparql/QuintQuerySource.js +152 -1
- package/dist/storage/sparql/QuintQuerySource.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +1 -0
- package/dist/storage/sparql/SubgraphQueryEngine.js +6 -2
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.jsonld +4 -0
- package/dist/subdomain/SubdomainClient.d.ts +3 -3
- package/dist/subdomain/SubdomainClient.js +1 -1
- package/dist/subdomain/SubdomainClient.js.map +1 -1
- package/dist/subdomain/SubdomainService.d.ts +15 -16
- package/dist/subdomain/SubdomainService.js +80 -54
- package/dist/subdomain/SubdomainService.js.map +1 -1
- package/dist/subdomain/SubdomainService.jsonld +22 -26
- package/dist/supervisor/Supervisor.d.ts +7 -2
- package/dist/supervisor/Supervisor.js +33 -1
- package/dist/supervisor/Supervisor.js.map +1 -1
- package/dist/test-utils/index.d.ts +4 -0
- package/dist/test-utils/index.js +8 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/no-auth-xpod.d.ts +11 -0
- package/dist/test-utils/no-auth-xpod.js +25 -0
- package/dist/test-utils/no-auth-xpod.js.map +1 -0
- package/dist/test-utils/seed-pod.d.ts +5 -0
- package/dist/test-utils/seed-pod.js +61 -0
- package/dist/test-utils/seed-pod.js.map +1 -0
- package/package.json +23 -5
- package/templates/identity/account/create-pod.html.ejs +110 -0
- package/templates/main.html.ejs +10 -0
- package/dist/api/handlers/DevHandler.d.ts +0 -18
- package/dist/api/handlers/DevHandler.js +0 -276
- package/dist/api/handlers/DevHandler.js.map +0 -1
- package/dist/api/handlers/SignalHandler.d.ts +0 -13
- package/dist/api/handlers/SignalHandler.js +0 -122
- package/dist/api/handlers/SignalHandler.js.map +0 -1
- package/dist/gateway/Proxy.d.ts +0 -24
- package/dist/gateway/Proxy.js +0 -209
- package/dist/gateway/Proxy.js.map +0 -1
- package/dist/gateway/Supervisor.d.ts +0 -2
- package/dist/gateway/Supervisor.js +0 -7
- package/dist/gateway/Supervisor.js.map +0 -1
- package/dist/gateway/port-finder.d.ts +0 -4
- package/dist/gateway/port-finder.js +0 -15
- package/dist/gateway/port-finder.js.map +0 -1
- package/dist/gateway/types.d.ts +0 -1
- package/dist/gateway/types.js +0 -3
- package/dist/gateway/types.js.map +0 -1
- package/dist/http/SignalInterceptHttpHandler.d.ts +0 -24
- package/dist/http/SignalInterceptHttpHandler.js +0 -47
- package/dist/http/SignalInterceptHttpHandler.js.map +0 -1
- package/dist/http/SignalInterceptHttpHandler.jsonld +0 -103
- package/dist/http/admin/EdgeNodeSignalHttpHandler.d.ts +0 -71
- package/dist/http/admin/EdgeNodeSignalHttpHandler.js +0 -674
- package/dist/http/admin/EdgeNodeSignalHttpHandler.js.map +0 -1
- package/dist/http/admin/EdgeNodeSignalHttpHandler.jsonld +0 -406
- package/dist/http/cluster/PodMigrationHttpHandler.jsonld +0 -169
- package/dist/quota/DefaultQuotaService.d.ts +0 -16
- package/dist/quota/DefaultQuotaService.js +0 -37
- package/dist/quota/DefaultQuotaService.js.map +0 -1
- package/dist/quota/DefaultQuotaService.jsonld +0 -85
- package/dist/service/EdgeNodeHeartbeatService.js.map +0 -1
- package/dist/service/PodMigrationService.jsonld +0 -76
- package/dist/storage/MigratableDataAccessor.d.ts +0 -63
- package/dist/storage/MigratableDataAccessor.js +0 -11
- package/dist/storage/MigratableDataAccessor.js.map +0 -1
- package/dist/storage/MigratableDataAccessor.jsonld +0 -60
- package/dist/storage/accessors/TieredMinioDataAccessor.d.ts +0 -150
- package/dist/storage/accessors/TieredMinioDataAccessor.js +0 -582
- package/dist/storage/accessors/TieredMinioDataAccessor.js.map +0 -1
- package/dist/storage/accessors/TieredMinioDataAccessor.jsonld +0 -333
- package/static/app/assets/index.css +0 -1
- package/static/app/assets/main.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinioDataAccessor.js","sourceRoot":"","sources":["../../../src/storage/accessors/MinioDataAccessor.ts"],"names":[],"mappings":";;;AAAA,iCAA+C;AAC/C,iEAAqD;AAIrD,8DAuBiC;AASjC,MAAa,iBAAiB;IAM5B,YACE,cAAoC,EACpC,SAAiB,EACjB,SAAiB,EACjB,QAAgB,EAChB,UAAkB;QAVD,WAAM,GAAG,IAAA,oCAAY,EAAC,IAAI,CAAC,CAAC;QAY7C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,6FAA6F;QAC7F,IAAI,QAAgB,CAAC;QACrB,IAAI,IAAwB,CAAC;QAC7B,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACtE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC9B,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;YACxB,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrD,MAAM,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,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C,CAAC;QACD,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAA;QACpD,IAAI,iBAAiB,KAAK,SAAS;eAC9B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,sDAAsD;QACtD,OAAO,iBAAiB,CAAC,UAAU,CAAC;IACtC,CAAC;IAES,cAAc,CAAC,IAAkB,EAAE,QAAwB;QACnE,OAAO,IAAI,yCAAsB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;CACF;AA5RD,8CA4RC","sourcesContent":["import { Client, BucketItemStat } from 'minio';\nimport { getLoggerFor } from 'global-logger-factory';\nimport type { DataAccessor } from '@solid/community-server';\nimport type { Readable } from 'node:stream';\nimport { DataFactory } from 'n3';\nimport {\n RepresentationMetadata,\n \n NotFoundHttpError,\n guardStream,\n isContainerIdentifier,\n isContainerPath,\n joinFilePath,\n UnsupportedMediaTypeHttpError,\n CONTENT_TYPE_TERM,\n DC,\n IANA,\n LDP,\n POSIX,\n RDF,\n SOLID_META,\n XSD,\n parseQuads,\n serializeQuads,\n addResourceMetadata,\n updateModifiedDate,\n toLiteral,\n toNamedTerm,\n} from '@solid/community-server';\nimport type { Guarded } from '@solid/community-server';\nimport type { FileIdentifierMapper, ResourceLink } from '@solid/community-server';\nimport type { \n ResourceIdentifier,\n Representation,\n MetadataRecord\n} from '@solid/community-server';\n\nexport class MinioDataAccessor implements DataAccessor {\n protected readonly logger = getLoggerFor(this);\n protected readonly resourceMapper: FileIdentifierMapper;\n private readonly client: Client;\n private readonly bucketName: string;\n\n public constructor(\n resourceMapper: FileIdentifierMapper,\n accessKey: string,\n secretKey: string,\n endpoint: string,\n bucketName: string,\n ) {\n this.resourceMapper = resourceMapper;\n\n // Parse endpoint - supports both URL format (http://host:port) and simple format (host:port)\n let endPoint: string;\n let port: number | undefined;\n let useSSL = false;\n\n if (endpoint.startsWith('http://') || endpoint.startsWith('https://')) {\n const url = new URL(endpoint);\n endPoint = url.hostname;\n port = url.port ? parseInt(url.port, 10) : undefined;\n useSSL = url.protocol === 'https:';\n } else {\n const parts = endpoint.split(':');\n endPoint = parts[0];\n port = parts[1] ? parseInt(parts[1], 10) : undefined;\n }\n\n this.client = new Client({\n accessKey,\n secretKey,\n endPoint,\n port,\n useSSL,\n });\n this.bucketName = bucketName;\n this.logger.info(`MinioDataAccessor initialized with endpoint: ${endPoint}:${port} (SSL: ${useSSL})`)\n }\n\n /**\n * Should throw a NotImplementedHttpError if the DataAccessor does not support storing the given Representation.\n *\n * @param representation - Incoming Representation.\n *\n * @throws BadRequestHttpError\n * If it does not support the incoming data.\n */\n public async canHandle(representation: Representation): Promise<void> {\n if (!representation.binary) {\n throw new UnsupportedMediaTypeHttpError('Only binary data is supported.');\n }\n }\n\n /**\n * Returns a data stream stored for the given identifier.\n * It can be assumed that the incoming identifier will always correspond to a document.\n *\n * @param identifier - Identifier for which the data is requested.\n */\n public async getData(identifier: ResourceIdentifier): Promise<Guarded<Readable>> {\n const url = new URL(identifier.path)\n const stream = await this.client.getObject(this.bucketName, url.pathname);\n return guardStream(stream);\n }\n\n /**\n * Returns the metadata corresponding to the identifier.\n * If possible, it is suggested to add a `posix:size` triple to the metadata indicating the binary size.\n * This is necessary for range requests.\n *\n * @param identifier - Identifier for which the metadata is requested.\n */\n public async getMetadata(identifier: ResourceIdentifier): Promise<RepresentationMetadata> {\n const url = new URL(identifier.path)\n const link = await this.resourceMapper.mapUrlToFilePath(identifier, false);\n const isDirectory = identifier.path.endsWith('/');\n const objectName = isDirectory ? `${url.pathname}/.container` : url.pathname;\n let stats: BucketItemStat;\n try {\n stats = await this.client.statObject(this.bucketName, objectName);\n } catch (error) {\n throw new NotFoundHttpError();\n }\n if (!isContainerIdentifier(identifier) && !isDirectory) {\n return this.getFileMetadata(link, stats);\n }\n if (isContainerIdentifier(identifier) && isDirectory) {\n return this.getDirectoryMetadata(link, stats);\n }\n throw new NotFoundHttpError();\n }\n\n /**\n * Returns metadata for all resources in the requested container.\n * This should not be all metadata of those resources (but it can be),\n * but instead the main metadata you want to show in situations\n * where all these resources are presented simultaneously.\n * Generally this would be metadata that is present for all of these resources,\n * such as resource type or last modified date.\n *\n * It can be safely assumed that the incoming identifier will always correspond to a container.\n *\n * @param identifier - Identifier of the parent container.\n */\n public async* getChildren(identifier: ResourceIdentifier): AsyncIterableIterator<RepresentationMetadata> {\n const url = new URL(identifier.path)\n const objects = this.client.listObjectsV2(this.bucketName, url.pathname);\n for await (const object of objects) {\n const metadata = await this.getMetadata(object);\n yield metadata;\n }\n }\n\n /**\n * Writes data and metadata for a document.\n * If any data and/or metadata exist for the given identifier, it should be overwritten.\n *\n * @param identifier - Identifier of the resource.\n * @param data - Data to store.\n * @param metadata - Metadata to store.\n */\n public async writeDocument(identifier: ResourceIdentifier, data: Guarded<Readable>, metadata: RepresentationMetadata): Promise<void> {\n const url = new URL(identifier.path);\n const link = await this.resourceMapper.mapUrlToFilePath(identifier, false);\n const itemMetadata = this.encodeMetadata(link, metadata);\n try {\n await this.client.putObject(\n this.bucketName,\n url.pathname,\n data,\n metadata.contentLength,\n itemMetadata || undefined,\n );\n } catch (error) {\n this.logger.error(`Error writing document: ${identifier.path} ${error}`)\n throw error;\n }\n }\n\n /**\n * Writes metadata for a container.\n * If the container does not exist yet it should be created,\n * if it does its metadata should be overwritten, except for the containment triples.\n *\n * @param identifier - Identifier of the container.\n * @param metadata - Metadata to store.\n */\n public async writeContainer(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {\n const url = new URL(identifier.path)\n const link = await this.resourceMapper.mapUrlToFilePath(identifier, false);\n await this.client.putObject(\n this.bucketName,\n `${url.pathname}/.container`,\n Buffer.from(''),\n metadata.contentLength,\n this.encodeMetadata(link, metadata) || undefined,\n );\n }\n\n /**\n * Writes metadata for a resource.\n * It can safely be assumed that the subject resource already exists.\n *\n * @param identifier - Identifier of the subject resource.\n * @param metadata - Metadata to store.\n */\n public async writeMetadata(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {\n throw new Error('Minio does not support writing metadata for a resource.');\n }\n\n /**\n * Deletes the resource and its corresponding metadata.\n *\n * Solid, §5.4: \"When a contained resource is deleted, the server MUST also remove the corresponding containment\n * triple, which has the effect of removing the deleted resource from the containing container.\"\n * https://solid.github.io/specification/protocol#deleting-resources\n *\n * @param identifier - Resource to delete.\n */\n public async deleteResource(identifier: ResourceIdentifier): Promise<void> {\n const link = new URL(identifier.path)\n await this.client.removeObject(this.bucketName, link.pathname);\n }\n\n /**\n * Reads and generates all metadata relevant for the given file,\n * ingesting it into a RepresentationMetadata object.\n *\n * @param link - Path related metadata.\n * @param stats - Stats object of the corresponding file.\n */\n private async getFileMetadata(link: ResourceLink, stats: BucketItemStat): Promise<RepresentationMetadata> {\n const metadata = await this.getBaseMetadata(link, stats, false);\n // If the resource is using an unsupported contentType, the original contentType was written to the metadata file.\n // As a result, we should only set the contentType derived from the file path,\n // when no previous metadata entry for contentType is present.\n if (typeof metadata.contentType === 'undefined') {\n metadata.set(CONTENT_TYPE_TERM, link.contentType);\n }\n return metadata;\n }\n\n /**\n * Reads and generates all metadata relevant for the given directory,\n * ingesting it into a RepresentationMetadata object.\n *\n * @param link - Path related metadata.\n * @param stats - Stats object of the corresponding directory.\n */\n private async getDirectoryMetadata(link: ResourceLink, stats: BucketItemStat): Promise<RepresentationMetadata> {\n return this.getBaseMetadata(link, stats, true);\n }\n \n /**\n * Generates metadata relevant for any resources stored by this accessor.\n *\n * @param link - Path related metadata.\n * @param stats - Stats objects of the corresponding directory.\n * @param isContainer - If the path points to a container (directory) or not.\n */\n private async getBaseMetadata(link: ResourceLink, stats: BucketItemStat, isContainer: boolean): Promise<RepresentationMetadata> {\n const metadata = this.decodeMetadata(link, stats.metaData);\n addResourceMetadata(metadata, isContainer);\n this.addPosixMetadata(metadata, stats, isContainer);\n return metadata;\n }\n \n /**\n * Helper function to add file system related metadata.\n *\n * @param metadata - metadata object to add to\n * @param stats - Stats of the file/directory corresponding to the resource.\n */\n private addPosixMetadata(metadata: RepresentationMetadata, stats: BucketItemStat, isDirectory: boolean): void {\n updateModifiedDate(metadata, stats.lastModified);\n metadata.add(\n POSIX.terms.mtime,\n toLiteral(Math.floor(stats.lastModified.getTime() / 1000), XSD.terms.integer),\n SOLID_META.terms.ResponseMetadata,\n );\n if (!isDirectory) {\n metadata.add(\n POSIX.terms.size,\n toLiteral(stats.size, XSD.terms.integer),\n SOLID_META.terms.ResponseMetadata,\n );\n }\n }\n\n /**\n * encode the metadata of the resource to string.\n *\n * @param link - Path related metadata of the resource.\n * @param metadata - Metadata to write.\n *\n * @returns string of metadata.\n */\n protected encodeMetadata(link: ResourceLink, metadata: RepresentationMetadata): object | null {\n // These are stored by file system conventions\n metadata.remove(RDF.terms.type, LDP.terms.Resource);\n metadata.remove(RDF.terms.type, LDP.terms.Container);\n metadata.remove(RDF.terms.type, LDP.terms.BasicContainer);\n metadata.removeAll(DC.terms.modified);\n // When writing metadata for a document, only remove the content-type when dealing with a supported media type.\n // A media type is supported if the FileIdentifierMapper can correctly store it.\n // This allows restoring the appropriate content-type on data read (see getFileMetadata).\n if (isContainerPath(link.filePath) || typeof metadata.contentType !== 'undefined') {\n metadata.removeAll(CONTENT_TYPE_TERM);\n }\n const contentTypeObject = metadata.contentTypeObject\n if (contentTypeObject === undefined\n || Object.keys(contentTypeObject.parameters).length === 0) {\n return null;\n }\n // Write metadata to file if there are quads remaining\n return contentTypeObject.parameters;\n }\n\n protected decodeMetadata(link: ResourceLink, metadata: MetadataRecord): RepresentationMetadata {\n return new RepresentationMetadata(link.identifier, metadata);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MinioDataAccessor.js","sourceRoot":"","sources":["../../../src/storage/accessors/MinioDataAccessor.ts"],"names":[],"mappings":";;;AAAA,iCAA+C;AAC/C,iEAAqD;AAIrD,8DAuBiC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,CAAC;QACxC,CAAC;QACD,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAA;QACpD,IAAI,iBAAiB,KAAK,SAAS;eAC9B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,sDAAsD;QACtD,OAAO,iBAAiB,CAAC,UAAU,CAAC;IACtC,CAAC;IAES,cAAc,CAAC,IAAkB,EAAE,QAAwB;QACnE,OAAO,IAAI,yCAAsB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;CACF;AAvSD,8CAuSC","sourcesContent":["import { Client, BucketItemStat } from 'minio';\nimport { getLoggerFor } from 'global-logger-factory';\nimport type { DataAccessor } from '@solid/community-server';\nimport type { Readable } from 'node:stream';\nimport { DataFactory } from 'n3';\nimport {\n RepresentationMetadata,\n \n NotFoundHttpError,\n guardStream,\n isContainerIdentifier,\n isContainerPath,\n joinFilePath,\n UnsupportedMediaTypeHttpError,\n CONTENT_TYPE_TERM,\n DC,\n IANA,\n LDP,\n POSIX,\n RDF,\n SOLID_META,\n XSD,\n parseQuads,\n serializeQuads,\n addResourceMetadata,\n updateModifiedDate,\n toLiteral,\n toNamedTerm,\n} from '@solid/community-server';\nimport type { Guarded } from '@solid/community-server';\nimport type { FileIdentifierMapper, ResourceLink } from '@solid/community-server';\nimport type { \n ResourceIdentifier,\n Representation,\n MetadataRecord\n} from '@solid/community-server';\n\nexport class MinioDataAccessor implements DataAccessor {\n protected readonly logger = getLoggerFor(this);\n protected readonly resourceMapper: FileIdentifierMapper;\n private readonly client: Client;\n private readonly bucketName: string;\n\n public constructor(\n resourceMapper: FileIdentifierMapper,\n accessKey: string,\n secretKey: string,\n endpoint: string,\n bucketName: string,\n ) {\n this.resourceMapper = resourceMapper;\n\n // Parse endpoint - supports both URL format (http://host:port) and simple format (host:port)\n let endPoint: string;\n let port: number | undefined;\n let useSSL = false;\n\n if (endpoint.startsWith('http://') || endpoint.startsWith('https://')) {\n const url = new URL(endpoint);\n endPoint = url.hostname;\n port = url.port ? parseInt(url.port, 10) : undefined;\n useSSL = url.protocol === 'https:';\n } else {\n const parts = endpoint.split(':');\n endPoint = parts[0];\n port = parts[1] ? parseInt(parts[1], 10) : undefined;\n }\n\n this.client = new Client({\n accessKey,\n secretKey,\n endPoint,\n port,\n useSSL,\n });\n this.bucketName = bucketName;\n this.logger.info(`MinioDataAccessor initialized with endpoint: ${endPoint}:${port} (SSL: ${useSSL})`)\n }\n\n /**\n * Should throw a NotImplementedHttpError if the DataAccessor does not support storing the given Representation.\n *\n * @param representation - Incoming Representation.\n *\n * @throws BadRequestHttpError\n * If it does not support the incoming data.\n */\n public async canHandle(representation: Representation): Promise<void> {\n if (!representation.binary) {\n throw new UnsupportedMediaTypeHttpError('Only binary data is supported.');\n }\n }\n\n /**\n * Returns a data stream stored for the given identifier.\n * It can be assumed that the incoming identifier will always correspond to a document.\n *\n * @param identifier - Identifier for which the data is requested.\n */\n public async getData(identifier: ResourceIdentifier): Promise<Guarded<Readable>> {\n const url = new URL(identifier.path)\n const stream = await this.client.getObject(this.bucketName, url.pathname);\n return guardStream(stream);\n }\n\n /**\n * Generate a presigned GET URL for the given resource.\n * @param identifier - Resource identifier.\n * @param expires - URL expiry in seconds (default 3600).\n */\n public async getPresignedUrl(identifier: ResourceIdentifier, expires = 3600): Promise<string> {\n const url = new URL(identifier.path);\n const objectKey = url.pathname.replace(/^\\//, '');\n return this.client.presignedGetObject(this.bucketName, objectKey, expires);\n }\n\n /**\n * Returns the metadata corresponding to the identifier.\n * If possible, it is suggested to add a `posix:size` triple to the metadata indicating the binary size.\n * This is necessary for range requests.\n *\n * @param identifier - Identifier for which the metadata is requested.\n */\n public async getMetadata(identifier: ResourceIdentifier): Promise<RepresentationMetadata> {\n const url = new URL(identifier.path)\n const link = await this.resourceMapper.mapUrlToFilePath(identifier, false);\n const isDirectory = identifier.path.endsWith('/');\n const objectName = isDirectory ? `${url.pathname}/.container` : url.pathname;\n let stats: BucketItemStat;\n try {\n stats = await this.client.statObject(this.bucketName, objectName);\n } catch (error) {\n throw new NotFoundHttpError();\n }\n if (!isContainerIdentifier(identifier) && !isDirectory) {\n return this.getFileMetadata(link, stats);\n }\n if (isContainerIdentifier(identifier) && isDirectory) {\n return this.getDirectoryMetadata(link, stats);\n }\n throw new NotFoundHttpError();\n }\n\n /**\n * Returns metadata for all resources in the requested container.\n * This should not be all metadata of those resources (but it can be),\n * but instead the main metadata you want to show in situations\n * where all these resources are presented simultaneously.\n * Generally this would be metadata that is present for all of these resources,\n * such as resource type or last modified date.\n *\n * It can be safely assumed that the incoming identifier will always correspond to a container.\n *\n * @param identifier - Identifier of the parent container.\n */\n public async* getChildren(identifier: ResourceIdentifier): AsyncIterableIterator<RepresentationMetadata> {\n const url = new URL(identifier.path)\n const objects = this.client.listObjectsV2(this.bucketName, url.pathname);\n for await (const object of objects) {\n const metadata = await this.getMetadata(object);\n yield metadata;\n }\n }\n\n /**\n * Writes data and metadata for a document.\n * If any data and/or metadata exist for the given identifier, it should be overwritten.\n *\n * @param identifier - Identifier of the resource.\n * @param data - Data to store.\n * @param metadata - Metadata to store.\n */\n public async writeDocument(identifier: ResourceIdentifier, data: Guarded<Readable>, metadata: RepresentationMetadata): Promise<void> {\n const url = new URL(identifier.path);\n const link = await this.resourceMapper.mapUrlToFilePath(identifier, false);\n const itemMetadata = this.encodeMetadata(link, metadata);\n try {\n await this.client.putObject(\n this.bucketName,\n url.pathname,\n data,\n metadata.contentLength,\n itemMetadata || undefined,\n );\n } catch (error) {\n this.logger.error(`Error writing document: ${identifier.path} ${error}`)\n throw error;\n }\n }\n\n /**\n * Writes metadata for a container.\n * If the container does not exist yet it should be created,\n * if it does its metadata should be overwritten, except for the containment triples.\n *\n * @param identifier - Identifier of the container.\n * @param metadata - Metadata to store.\n */\n public async writeContainer(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {\n const url = new URL(identifier.path)\n const link = await this.resourceMapper.mapUrlToFilePath(identifier, false);\n await this.client.putObject(\n this.bucketName,\n `${url.pathname}/.container`,\n Buffer.from(''),\n metadata.contentLength,\n this.encodeMetadata(link, metadata) || undefined,\n );\n }\n\n /**\n * Writes metadata for a resource.\n * It can safely be assumed that the subject resource already exists.\n *\n * @param identifier - Identifier of the subject resource.\n * @param metadata - Metadata to store.\n */\n public async writeMetadata(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {\n throw new Error('Minio does not support writing metadata for a resource.');\n }\n\n /**\n * Deletes the resource and its corresponding metadata.\n *\n * Solid, §5.4: \"When a contained resource is deleted, the server MUST also remove the corresponding containment\n * triple, which has the effect of removing the deleted resource from the containing container.\"\n * https://solid.github.io/specification/protocol#deleting-resources\n *\n * @param identifier - Resource to delete.\n */\n public async deleteResource(identifier: ResourceIdentifier): Promise<void> {\n const link = new URL(identifier.path)\n await this.client.removeObject(this.bucketName, link.pathname);\n }\n\n /**\n * Reads and generates all metadata relevant for the given file,\n * ingesting it into a RepresentationMetadata object.\n *\n * @param link - Path related metadata.\n * @param stats - Stats object of the corresponding file.\n */\n private async getFileMetadata(link: ResourceLink, stats: BucketItemStat): Promise<RepresentationMetadata> {\n const metadata = await this.getBaseMetadata(link, stats, false);\n // If the resource is using an unsupported contentType, the original contentType was written to the metadata file.\n // As a result, we should only set the contentType derived from the file path,\n // when no previous metadata entry for contentType is present.\n if (typeof metadata.contentType === 'undefined') {\n metadata.set(CONTENT_TYPE_TERM, link.contentType);\n }\n return metadata;\n }\n\n /**\n * Reads and generates all metadata relevant for the given directory,\n * ingesting it into a RepresentationMetadata object.\n *\n * @param link - Path related metadata.\n * @param stats - Stats object of the corresponding directory.\n */\n private async getDirectoryMetadata(link: ResourceLink, stats: BucketItemStat): Promise<RepresentationMetadata> {\n return this.getBaseMetadata(link, stats, true);\n }\n \n /**\n * Generates metadata relevant for any resources stored by this accessor.\n *\n * @param link - Path related metadata.\n * @param stats - Stats objects of the corresponding directory.\n * @param isContainer - If the path points to a container (directory) or not.\n */\n private async getBaseMetadata(link: ResourceLink, stats: BucketItemStat, isContainer: boolean): Promise<RepresentationMetadata> {\n const metadata = this.decodeMetadata(link, stats.metaData);\n addResourceMetadata(metadata, isContainer);\n this.addPosixMetadata(metadata, stats, isContainer);\n return metadata;\n }\n \n /**\n * Helper function to add file system related metadata.\n *\n * @param metadata - metadata object to add to\n * @param stats - Stats of the file/directory corresponding to the resource.\n */\n private addPosixMetadata(metadata: RepresentationMetadata, stats: BucketItemStat, isDirectory: boolean): void {\n updateModifiedDate(metadata, stats.lastModified);\n metadata.add(\n POSIX.terms.mtime,\n toLiteral(Math.floor(stats.lastModified.getTime() / 1000), XSD.terms.integer),\n SOLID_META.terms.ResponseMetadata,\n );\n if (!isDirectory) {\n metadata.add(\n POSIX.terms.size,\n toLiteral(stats.size, XSD.terms.integer),\n SOLID_META.terms.ResponseMetadata,\n );\n }\n }\n\n /**\n * encode the metadata of the resource to string.\n *\n * @param link - Path related metadata of the resource.\n * @param metadata - Metadata to write.\n *\n * @returns string of metadata.\n */\n protected encodeMetadata(link: ResourceLink, metadata: RepresentationMetadata): object | null {\n // These are stored by file system conventions\n metadata.remove(RDF.terms.type, LDP.terms.Resource);\n metadata.remove(RDF.terms.type, LDP.terms.Container);\n metadata.remove(RDF.terms.type, LDP.terms.BasicContainer);\n metadata.removeAll(DC.terms.modified);\n // When writing metadata for a document, only remove the content-type when dealing with a supported media type.\n // A media type is supported if the FileIdentifierMapper can correctly store it.\n // This allows restoring the appropriate content-type on data read (see getFileMetadata).\n if (isContainerPath(link.filePath) || typeof metadata.contentType !== 'undefined') {\n metadata.removeAll(CONTENT_TYPE_TERM);\n }\n const contentTypeObject = metadata.contentTypeObject\n if (contentTypeObject === undefined\n || Object.keys(contentTypeObject.parameters).length === 0) {\n return null;\n }\n // Write metadata to file if there are quads remaining\n return contentTypeObject.parameters;\n }\n\n protected decodeMetadata(link: ResourceLink, metadata: MetadataRecord): RepresentationMetadata {\n return new RepresentationMetadata(link.identifier, metadata);\n }\n}\n"]}
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"@id": "undefineds:dist/storage/accessors/MinioDataAccessor.jsonld#MinioDataAccessor__member_getData",
|
|
68
68
|
"memberFieldName": "getData"
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
"@id": "undefineds:dist/storage/accessors/MinioDataAccessor.jsonld#MinioDataAccessor__member_getPresignedUrl",
|
|
72
|
+
"memberFieldName": "getPresignedUrl"
|
|
73
|
+
},
|
|
70
74
|
{
|
|
71
75
|
"@id": "undefineds:dist/storage/accessors/MinioDataAccessor.jsonld#MinioDataAccessor__member_getMetadata",
|
|
72
76
|
"memberFieldName": "getMetadata"
|
|
@@ -14,7 +14,8 @@ export declare class MixDataAccessor implements DataAccessor {
|
|
|
14
14
|
protected readonly logger: import("global-logger-factory").Logger<unknown>;
|
|
15
15
|
private readonly structuredDataAccessor;
|
|
16
16
|
private readonly unstructuredDataAccessor;
|
|
17
|
-
|
|
17
|
+
private readonly presignedRedirectEnabled;
|
|
18
|
+
constructor(structuredDataAccessor: DataAccessor, unstructuredDataAccessor: DataAccessor, presignedRedirectEnabled?: boolean);
|
|
18
19
|
/**
|
|
19
20
|
* This accessor supports all types of data.
|
|
20
21
|
*/
|
|
@@ -13,10 +13,11 @@ const community_server_1 = require("@solid/community-server");
|
|
|
13
13
|
* to be used as the RDF storage backend.
|
|
14
14
|
*/
|
|
15
15
|
class MixDataAccessor {
|
|
16
|
-
constructor(structuredDataAccessor, unstructuredDataAccessor) {
|
|
16
|
+
constructor(structuredDataAccessor, unstructuredDataAccessor, presignedRedirectEnabled = false) {
|
|
17
17
|
this.logger = (0, global_logger_factory_1.getLoggerFor)(this);
|
|
18
18
|
this.structuredDataAccessor = structuredDataAccessor;
|
|
19
19
|
this.unstructuredDataAccessor = unstructuredDataAccessor;
|
|
20
|
+
this.presignedRedirectEnabled = presignedRedirectEnabled;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* This accessor supports all types of data.
|
|
@@ -33,6 +34,16 @@ class MixDataAccessor {
|
|
|
33
34
|
async getData(identifier) {
|
|
34
35
|
const metadata = await this.getMetadata(identifier);
|
|
35
36
|
if (this.isUnstructured(metadata)) {
|
|
37
|
+
// When presigned redirect is enabled and the unstructured accessor supports it,
|
|
38
|
+
// generate a presigned URL and throw FoundHttpError to trigger a 302 redirect.
|
|
39
|
+
if (this.presignedRedirectEnabled) {
|
|
40
|
+
const accessor = this.unstructuredDataAccessor;
|
|
41
|
+
if (typeof accessor.getPresignedUrl === 'function') {
|
|
42
|
+
const presignedUrl = await accessor.getPresignedUrl(identifier);
|
|
43
|
+
this.logger.debug(`Presigned redirect: ${identifier.path}`);
|
|
44
|
+
throw new community_server_1.FoundHttpError(presignedUrl);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
return await this.unstructuredDataAccessor.getData(identifier);
|
|
37
48
|
}
|
|
38
49
|
return await this.structuredDataAccessor.getData(identifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixDataAccessor.js","sourceRoot":"","sources":["../../../src/storage/accessors/MixDataAccessor.ts"],"names":[],"mappings":";;;AACA,iEAAqD;AAGrD,8DAIiC;AAQjC;;;;;;;;GAQG;AACH,MAAa,eAAe;IAM1B,YACE,sBAAoC,EACpC,wBAAsC;QAPrB,WAAM,GAAG,IAAA,oCAAY,EAAC,IAAI,CAAC,CAAC;QAS7C,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IAC3D,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,cAA8B;QACnD,OAAO,KAAK,CAAC,CAAC;IAChB,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,QAAgC;QACrD,OAAO,QAAQ,CAAC,WAAW,KAAK,iCAAc,CAAC;IACjD,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C,CAAC;QAC7E,CAAC;QACD,OAAO,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,yBAAyB,CACrC,UAA8B,EAC9B,IAAuB,EACvB,QAAgC;QAEhC,gDAAgD;QAChD,MAAM,IAAI,CAAC,wBAAwB,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE9E,mEAAmE;QACnE,IAAI,eAAe,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAElF,2BAA2B;QAC3B,MAAM,QAAQ,GAAW,EAAE,CAAC;QAC5B,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;QACD,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAEtC,sCAAsC;QACtC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,UAAU,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;YAC7E,yCAAyC;YACzC,MAAM,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAnJD,0CAmJC","sourcesContent":["import type { Readable } from 'stream';\nimport { getLoggerFor } from 'global-logger-factory';\n\nimport type { Quad } from '@rdfjs/types';\nimport { \n isContainerIdentifier,\n RepresentationMetadata,\n INTERNAL_QUADS,\n} from '@solid/community-server';\nimport type {\n Representation,\n ResourceIdentifier,\n Guarded,\n DataAccessor,\n} from '@solid/community-server';\n\n/**\n * MixDataAccessor - Routes data to appropriate storage based on content type\n * \n * - RDF data (internal/quads) -> structuredDataAccessor (Quadstore or QuintStore)\n * - Other data (binary, text, etc.) -> unstructuredDataAccessor (FileSystem, Minio, etc.)\n * \n * This uses composition instead of inheritance, allowing any DataAccessor\n * to be used as the RDF storage backend.\n */\nexport class MixDataAccessor implements DataAccessor {\n protected readonly logger = getLoggerFor(this);\n \n private readonly structuredDataAccessor: DataAccessor;\n private readonly unstructuredDataAccessor: DataAccessor;\n\n constructor(\n structuredDataAccessor: DataAccessor,\n unstructuredDataAccessor: DataAccessor,\n ) {\n this.structuredDataAccessor = structuredDataAccessor;\n this.unstructuredDataAccessor = unstructuredDataAccessor;\n }\n\n /**\n * This accessor supports all types of data.\n */\n public async canHandle(representation: Representation): Promise<void> {\n return void 0;\n }\n\n /**\n * Checks if the given representation is unstructured (non-RDF).\n */\n private isUnstructured(metadata: RepresentationMetadata): boolean {\n return metadata.contentType !== INTERNAL_QUADS;\n }\n\n public async getData(identifier: ResourceIdentifier): Promise<Guarded<Readable>> {\n const metadata = await this.getMetadata(identifier);\n if (this.isUnstructured(metadata)) {\n return await this.unstructuredDataAccessor.getData(identifier);\n }\n return await this.structuredDataAccessor.getData(identifier);\n }\n\n public async getMetadata(identifier: ResourceIdentifier): Promise<RepresentationMetadata> {\n // Metadata is always stored in the structured accessor\n const metadata = await this.structuredDataAccessor.getMetadata(identifier);\n\n // For resources without explicit content type, default to RDF\n // This includes containers (which are always RDF) and documents without contentType\n if (!metadata.contentType) {\n metadata.contentType = INTERNAL_QUADS;\n }\n\n return metadata;\n }\n\n public async* getChildren(identifier: ResourceIdentifier): AsyncIterableIterator<RepresentationMetadata> {\n // Children metadata is stored in the structured accessor\n yield* this.structuredDataAccessor.getChildren(identifier);\n }\n\n public async writeContainer(\n identifier: ResourceIdentifier,\n metadata: RepresentationMetadata,\n ): Promise<void> {\n // Container metadata goes to structured storage\n // Also create in unstructured if it needs to store files\n if (this.isUnstructured(metadata)) {\n await this.unstructuredDataAccessor.writeContainer(identifier, metadata);\n }\n await this.structuredDataAccessor.writeContainer(identifier, metadata);\n }\n\n public async writeDocument(\n identifier: ResourceIdentifier,\n data: Guarded<Readable>,\n metadata: RepresentationMetadata,\n ): Promise<void> {\n if (this.isUnstructured(metadata)) {\n return await this.writeUnstructuredDocument(identifier, data, metadata);\n }\n return await this.structuredDataAccessor.writeDocument(identifier, data, metadata);\n }\n\n public async writeMetadata(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {\n // Metadata always goes to structured storage\n return await this.structuredDataAccessor.writeMetadata(identifier, metadata);\n }\n\n public async deleteResource(identifier: ResourceIdentifier): Promise<void> {\n const metadata = await this.getMetadata(identifier);\n \n // Try to delete from unstructured storage if applicable\n if (this.isUnstructured(metadata)) {\n try {\n await this.unstructuredDataAccessor.deleteResource(identifier);\n } catch (error: any) {\n // Ignore file not found errors\n if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') {\n throw error;\n }\n }\n }\n \n // Always delete from structured storage (contains metadata)\n return await this.structuredDataAccessor.deleteResource(identifier);\n }\n\n /**\n * Execute SPARQL UPDATE on structured data accessor.\n * Delegates to the underlying structuredDataAccessor if it supports SPARQL.\n */\n public async executeSparqlUpdate(query: string, baseIri?: string): Promise<void> {\n const accessor = this.structuredDataAccessor as { executeSparqlUpdate?: (query: string, baseIri?: string) => Promise<void> };\n if (typeof accessor.executeSparqlUpdate !== 'function') {\n throw new Error('Structured data accessor does not support SPARQL UPDATE');\n }\n return accessor.executeSparqlUpdate(query, baseIri);\n }\n\n /**\n * Write unstructured document: store data in unstructured accessor,\n * then save metadata in structured accessor.\n */\n private async writeUnstructuredDocument(\n identifier: ResourceIdentifier,\n data: Guarded<Readable>,\n metadata: RepresentationMetadata,\n ): Promise<void> {\n // Write the actual data to unstructured storage\n await this.unstructuredDataAccessor.writeDocument(identifier, data, metadata);\n \n // Get the metadata from unstructured storage (includes size, etc.)\n let updatedMetadata = await this.unstructuredDataAccessor.getMetadata(identifier);\n \n // Filter out invalid quads\n const removing: Quad[] = [];\n for (const quad of updatedMetadata.quads()) {\n if (!/^http/.test(quad.predicate.value)) {\n removing.push(quad);\n }\n }\n updatedMetadata.removeQuads(removing);\n \n // Save metadata to structured storage\n try {\n await this.structuredDataAccessor.writeMetadata(identifier, updatedMetadata);\n } catch (error) {\n this.logger.error(`Error writing metadata for ${identifier.path}: ${error}`);\n // Rollback: delete the unstructured data\n await this.unstructuredDataAccessor.deleteResource(identifier);\n throw error;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MixDataAccessor.js","sourceRoot":"","sources":["../../../src/storage/accessors/MixDataAccessor.ts"],"names":[],"mappings":";;;AACA,iEAAqD;AAGrD,8DAKiC;AAQjC;;;;;;;;GAQG;AACH,MAAa,eAAe;IAO1B,YACE,sBAAoC,EACpC,wBAAsC,EACtC,wBAAwB,GAAG,KAAK;QATf,WAAM,GAAG,IAAA,oCAAY,EAAC,IAAI,CAAC,CAAC;QAW7C,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;QACzD,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IAC3D,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,cAA8B;QACnD,OAAO,KAAK,CAAC,CAAC;IAChB,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,QAAgC;QACrD,OAAO,QAAQ,CAAC,WAAW,KAAK,iCAAc,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,UAA8B;QACjD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC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AAC,CAAC;YAC7E,yCAAyC;YACzC,MAAM,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAhKD,0CAgKC","sourcesContent":["import type { Readable } from 'stream';\nimport { getLoggerFor } from 'global-logger-factory';\n\nimport type { Quad } from '@rdfjs/types';\nimport {\n isContainerIdentifier,\n RepresentationMetadata,\n INTERNAL_QUADS,\n FoundHttpError,\n} from '@solid/community-server';\nimport type {\n Representation,\n ResourceIdentifier,\n Guarded,\n DataAccessor,\n} from '@solid/community-server';\n\n/**\n * MixDataAccessor - Routes data to appropriate storage based on content type\n * \n * - RDF data (internal/quads) -> structuredDataAccessor (Quadstore or QuintStore)\n * - Other data (binary, text, etc.) -> unstructuredDataAccessor (FileSystem, Minio, etc.)\n * \n * This uses composition instead of inheritance, allowing any DataAccessor\n * to be used as the RDF storage backend.\n */\nexport class MixDataAccessor implements DataAccessor {\n protected readonly logger = getLoggerFor(this);\n \n private readonly structuredDataAccessor: DataAccessor;\n private readonly unstructuredDataAccessor: DataAccessor;\n private readonly presignedRedirectEnabled: boolean;\n\n constructor(\n structuredDataAccessor: DataAccessor,\n unstructuredDataAccessor: DataAccessor,\n presignedRedirectEnabled = false,\n ) {\n this.structuredDataAccessor = structuredDataAccessor;\n this.unstructuredDataAccessor = unstructuredDataAccessor;\n this.presignedRedirectEnabled = presignedRedirectEnabled;\n }\n\n /**\n * This accessor supports all types of data.\n */\n public async canHandle(representation: Representation): Promise<void> {\n return void 0;\n }\n\n /**\n * Checks if the given representation is unstructured (non-RDF).\n */\n private isUnstructured(metadata: RepresentationMetadata): boolean {\n return metadata.contentType !== INTERNAL_QUADS;\n }\n\n public async getData(identifier: ResourceIdentifier): Promise<Guarded<Readable>> {\n const metadata = await this.getMetadata(identifier);\n if (this.isUnstructured(metadata)) {\n // When presigned redirect is enabled and the unstructured accessor supports it,\n // generate a presigned URL and throw FoundHttpError to trigger a 302 redirect.\n if (this.presignedRedirectEnabled) {\n const accessor = this.unstructuredDataAccessor as { getPresignedUrl?: (id: ResourceIdentifier, expires?: number) => Promise<string> };\n if (typeof accessor.getPresignedUrl === 'function') {\n const presignedUrl = await accessor.getPresignedUrl(identifier);\n this.logger.debug(`Presigned redirect: ${identifier.path}`);\n throw new FoundHttpError(presignedUrl);\n }\n }\n return await this.unstructuredDataAccessor.getData(identifier);\n }\n return await this.structuredDataAccessor.getData(identifier);\n }\n\n public async getMetadata(identifier: ResourceIdentifier): Promise<RepresentationMetadata> {\n // Metadata is always stored in the structured accessor\n const metadata = await this.structuredDataAccessor.getMetadata(identifier);\n\n // For resources without explicit content type, default to RDF\n // This includes containers (which are always RDF) and documents without contentType\n if (!metadata.contentType) {\n metadata.contentType = INTERNAL_QUADS;\n }\n\n return metadata;\n }\n\n public async* getChildren(identifier: ResourceIdentifier): AsyncIterableIterator<RepresentationMetadata> {\n // Children metadata is stored in the structured accessor\n yield* this.structuredDataAccessor.getChildren(identifier);\n }\n\n public async writeContainer(\n identifier: ResourceIdentifier,\n metadata: RepresentationMetadata,\n ): Promise<void> {\n // Container metadata goes to structured storage\n // Also create in unstructured if it needs to store files\n if (this.isUnstructured(metadata)) {\n await this.unstructuredDataAccessor.writeContainer(identifier, metadata);\n }\n await this.structuredDataAccessor.writeContainer(identifier, metadata);\n }\n\n public async writeDocument(\n identifier: ResourceIdentifier,\n data: Guarded<Readable>,\n metadata: RepresentationMetadata,\n ): Promise<void> {\n if (this.isUnstructured(metadata)) {\n return await this.writeUnstructuredDocument(identifier, data, metadata);\n }\n return await this.structuredDataAccessor.writeDocument(identifier, data, metadata);\n }\n\n public async writeMetadata(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {\n // Metadata always goes to structured storage\n return await this.structuredDataAccessor.writeMetadata(identifier, metadata);\n }\n\n public async deleteResource(identifier: ResourceIdentifier): Promise<void> {\n const metadata = await this.getMetadata(identifier);\n \n // Try to delete from unstructured storage if applicable\n if (this.isUnstructured(metadata)) {\n try {\n await this.unstructuredDataAccessor.deleteResource(identifier);\n } catch (error: any) {\n // Ignore file not found errors\n if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') {\n throw error;\n }\n }\n }\n \n // Always delete from structured storage (contains metadata)\n return await this.structuredDataAccessor.deleteResource(identifier);\n }\n\n /**\n * Execute SPARQL UPDATE on structured data accessor.\n * Delegates to the underlying structuredDataAccessor if it supports SPARQL.\n */\n public async executeSparqlUpdate(query: string, baseIri?: string): Promise<void> {\n const accessor = this.structuredDataAccessor as { executeSparqlUpdate?: (query: string, baseIri?: string) => Promise<void> };\n if (typeof accessor.executeSparqlUpdate !== 'function') {\n throw new Error('Structured data accessor does not support SPARQL UPDATE');\n }\n return accessor.executeSparqlUpdate(query, baseIri);\n }\n\n /**\n * Write unstructured document: store data in unstructured accessor,\n * then save metadata in structured accessor.\n */\n private async writeUnstructuredDocument(\n identifier: ResourceIdentifier,\n data: Guarded<Readable>,\n metadata: RepresentationMetadata,\n ): Promise<void> {\n // Write the actual data to unstructured storage\n await this.unstructuredDataAccessor.writeDocument(identifier, data, metadata);\n \n // Get the metadata from unstructured storage (includes size, etc.)\n let updatedMetadata = await this.unstructuredDataAccessor.getMetadata(identifier);\n \n // Filter out invalid quads\n const removing: Quad[] = [];\n for (const quad of updatedMetadata.quads()) {\n if (!/^http/.test(quad.predicate.value)) {\n removing.push(quad);\n }\n }\n updatedMetadata.removeQuads(removing);\n \n // Save metadata to structured storage\n try {\n await this.structuredDataAccessor.writeMetadata(identifier, updatedMetadata);\n } catch (error) {\n this.logger.error(`Error writing metadata for ${identifier.path}: ${error}`);\n // Rollback: delete the unstructured data\n await this.unstructuredDataAccessor.deleteResource(identifier);\n throw error;\n }\n }\n}\n"]}
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
],
|
|
15
15
|
"comment": "MixDataAccessor - Routes data to appropriate storage based on content type - RDF data (internal/quads) -> structuredDataAccessor (Quadstore or QuintStore) - Other data (binary, text, etc.) -> unstructuredDataAccessor (FileSystem, Minio, etc.) This uses composition instead of inheritance, allowing any DataAccessor to be used as the RDF storage backend.",
|
|
16
16
|
"parameters": [
|
|
17
|
+
{
|
|
18
|
+
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor_presignedRedirectEnabled",
|
|
19
|
+
"range": {
|
|
20
|
+
"@type": "ParameterRangeUnion",
|
|
21
|
+
"parameterRangeElements": [
|
|
22
|
+
"xsd:boolean",
|
|
23
|
+
{
|
|
24
|
+
"@type": "ParameterRangeUndefined"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
17
29
|
{
|
|
18
30
|
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor_structuredDataAccessor",
|
|
19
31
|
"range": "css:dist/storage/accessors/DataAccessor.jsonld#DataAccessor"
|
|
@@ -39,6 +51,10 @@
|
|
|
39
51
|
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor__member_unstructuredDataAccessor",
|
|
40
52
|
"memberFieldName": "unstructuredDataAccessor"
|
|
41
53
|
},
|
|
54
|
+
{
|
|
55
|
+
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor__member_presignedRedirectEnabled",
|
|
56
|
+
"memberFieldName": "presignedRedirectEnabled"
|
|
57
|
+
},
|
|
42
58
|
{
|
|
43
59
|
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor__member_constructor",
|
|
44
60
|
"memberFieldName": "constructor"
|
|
@@ -94,6 +110,9 @@
|
|
|
94
110
|
},
|
|
95
111
|
{
|
|
96
112
|
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor_unstructuredDataAccessor"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"@id": "undefineds:dist/storage/accessors/MixDataAccessor.jsonld#MixDataAccessor_presignedRedirectEnabled"
|
|
97
116
|
}
|
|
98
117
|
]
|
|
99
118
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RedisLocker } from '@solid/community-server';
|
|
2
|
+
export interface UrlAwareRedisLockerOptions {
|
|
3
|
+
redisClient?: string;
|
|
4
|
+
attemptSettings_retryCount?: number;
|
|
5
|
+
attemptSettings_retryDelay?: number;
|
|
6
|
+
attemptSettings_retryJitter?: number;
|
|
7
|
+
namespacePrefix?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 扩展 CSS RedisLocker,支持 redis:// 和 rediss:// URL 格式。
|
|
11
|
+
*
|
|
12
|
+
* CSS 原生 RedisLocker.createRedisClient 是 private 的,无法 override。
|
|
13
|
+
* 这里在构造函数中检测 URL 格式,如果是 URL 则用 ioredis 直接创建连接,
|
|
14
|
+
* 替换掉父类构造函数中创建的(会报错的)连接。
|
|
15
|
+
*/
|
|
16
|
+
export declare class UrlAwareRedisLocker extends RedisLocker {
|
|
17
|
+
constructor(options?: UrlAwareRedisLockerOptions);
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UrlAwareRedisLocker = void 0;
|
|
7
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
|
+
const community_server_1 = require("@solid/community-server");
|
|
9
|
+
const REDIS_LUA_SCRIPTS = (() => {
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
|
+
return require('@solid/community-server/dist/util/locking/scripts/RedisLuaScripts').REDIS_LUA_SCRIPTS;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
/**
|
|
19
|
+
* 扩展 CSS RedisLocker,支持 redis:// 和 rediss:// URL 格式。
|
|
20
|
+
*
|
|
21
|
+
* CSS 原生 RedisLocker.createRedisClient 是 private 的,无法 override。
|
|
22
|
+
* 这里在构造函数中检测 URL 格式,如果是 URL 则用 ioredis 直接创建连接,
|
|
23
|
+
* 替换掉父类构造函数中创建的(会报错的)连接。
|
|
24
|
+
*/
|
|
25
|
+
class UrlAwareRedisLocker extends community_server_1.RedisLocker {
|
|
26
|
+
constructor(options = {}) {
|
|
27
|
+
const redisClient = options.redisClient ?? '127.0.0.1:6379';
|
|
28
|
+
const attemptSettings = {
|
|
29
|
+
retryCount: options.attemptSettings_retryCount ?? -1,
|
|
30
|
+
retryDelay: options.attemptSettings_retryDelay ?? 50,
|
|
31
|
+
retryJitter: options.attemptSettings_retryJitter ?? 30,
|
|
32
|
+
};
|
|
33
|
+
const redisSettings = {
|
|
34
|
+
namespacePrefix: options.namespacePrefix ?? '',
|
|
35
|
+
};
|
|
36
|
+
const isUrl = redisClient.startsWith('redis://') || redisClient.startsWith('rediss://');
|
|
37
|
+
if (isUrl) {
|
|
38
|
+
// 传一个合法的 host:port 给父类,避免它报错
|
|
39
|
+
super('127.0.0.1:6379', attemptSettings, redisSettings);
|
|
40
|
+
// 关闭父类创建的无用连接
|
|
41
|
+
const oldRedis = this.redis;
|
|
42
|
+
oldRedis.disconnect(false);
|
|
43
|
+
// 用 URL 创建真正的连接
|
|
44
|
+
const redis = new ioredis_1.default(redisClient);
|
|
45
|
+
// 注册 Lua 脚本
|
|
46
|
+
for (const [name, script] of Object.entries(REDIS_LUA_SCRIPTS)) {
|
|
47
|
+
redis.defineCommand(name, { numberOfKeys: 1, lua: script });
|
|
48
|
+
}
|
|
49
|
+
// 替换父类的 redis 实例
|
|
50
|
+
this.redis = redis;
|
|
51
|
+
this.redisRw = redis;
|
|
52
|
+
this.redisLock = redis;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
super(redisClient, attemptSettings, redisSettings);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.UrlAwareRedisLocker = UrlAwareRedisLocker;
|
|
60
|
+
//# sourceMappingURL=UrlAwareRedisLocker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlAwareRedisLocker.js","sourceRoot":"","sources":["../../../src/storage/locking/UrlAwareRedisLocker.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAC5B,8DAAsD;AAEtD,MAAM,iBAAiB,GAA2B,CAAC,GAAG,EAAE;IACtD,IAAI,CAAC;QACH,iEAAiE;QACjE,OAAO,OAAO,CAAC,mEAAmE,CAAC,CAAC,iBAAiB,CAAC;IACxG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAUL;;;;;;GAMG;AACH,MAAa,mBAAoB,SAAQ,8BAAW;IAClD,YAAY,UAAsC,EAAE;QAClD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,gBAAgB,CAAC;QAC5D,MAAM,eAAe,GAAG;YACtB,UAAU,EAAE,OAAO,CAAC,0BAA0B,IAAI,CAAC,CAAC;YACpD,UAAU,EAAE,OAAO,CAAC,0BAA0B,IAAI,EAAE;YACpD,WAAW,EAAE,OAAO,CAAC,2BAA2B,IAAI,EAAE;SACvD,CAAC;QACF,MAAM,aAAa,GAAG;YACpB,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,EAAE;SAC/C,CAAC;QAEF,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAExF,IAAI,KAAK,EAAE,CAAC;YACV,6BAA6B;YAC7B,KAAK,CAAC,gBAAgB,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;YAExD,cAAc;YACd,MAAM,QAAQ,GAAI,IAAY,CAAC,KAAc,CAAC;YAC9C,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAE3B,gBAAgB;YAChB,MAAM,KAAK,GAAG,IAAI,iBAAK,CAAC,WAAW,CAAC,CAAC;YAErC,YAAY;YACZ,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBAC/D,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YAC9D,CAAC;YAED,iBAAiB;YAChB,IAAY,CAAC,KAAK,GAAG,KAAK,CAAC;YAC3B,IAAY,CAAC,OAAO,GAAG,KAAK,CAAC;YAC7B,IAAY,CAAC,SAAS,GAAG,KAAK,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,WAAW,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["import Redis from 'ioredis';\nimport { RedisLocker } from '@solid/community-server';\n\nconst REDIS_LUA_SCRIPTS: Record<string, string> = (() => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require('@solid/community-server/dist/util/locking/scripts/RedisLuaScripts').REDIS_LUA_SCRIPTS;\n } catch {\n return {};\n }\n})();\n\nexport interface UrlAwareRedisLockerOptions {\n redisClient?: string;\n attemptSettings_retryCount?: number;\n attemptSettings_retryDelay?: number;\n attemptSettings_retryJitter?: number;\n namespacePrefix?: string;\n}\n\n/**\n * 扩展 CSS RedisLocker,支持 redis:// 和 rediss:// URL 格式。\n *\n * CSS 原生 RedisLocker.createRedisClient 是 private 的,无法 override。\n * 这里在构造函数中检测 URL 格式,如果是 URL 则用 ioredis 直接创建连接,\n * 替换掉父类构造函数中创建的(会报错的)连接。\n */\nexport class UrlAwareRedisLocker extends RedisLocker {\n constructor(options: UrlAwareRedisLockerOptions = {}) {\n const redisClient = options.redisClient ?? '127.0.0.1:6379';\n const attemptSettings = {\n retryCount: options.attemptSettings_retryCount ?? -1,\n retryDelay: options.attemptSettings_retryDelay ?? 50,\n retryJitter: options.attemptSettings_retryJitter ?? 30,\n };\n const redisSettings = {\n namespacePrefix: options.namespacePrefix ?? '',\n };\n\n const isUrl = redisClient.startsWith('redis://') || redisClient.startsWith('rediss://');\n\n if (isUrl) {\n // 传一个合法的 host:port 给父类,避免它报错\n super('127.0.0.1:6379', attemptSettings, redisSettings);\n\n // 关闭父类创建的无用连接\n const oldRedis = (this as any).redis as Redis;\n oldRedis.disconnect(false);\n\n // 用 URL 创建真正的连接\n const redis = new Redis(redisClient);\n\n // 注册 Lua 脚本\n for (const [name, script] of Object.entries(REDIS_LUA_SCRIPTS)) {\n redis.defineCommand(name, { numberOfKeys: 1, lua: script });\n }\n\n // 替换父类的 redis 实例\n (this as any).redis = redis;\n (this as any).redisRw = redis;\n (this as any).redisLock = redis;\n } else {\n super(redisClient, attemptSettings, redisSettings);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@undefineds.co/xpod/^0.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^8.0.0/components/context.jsonld"
|
|
5
|
+
],
|
|
6
|
+
"@id": "npmd:@undefineds.co/xpod",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker",
|
|
10
|
+
"@type": "Class",
|
|
11
|
+
"requireElement": "UrlAwareRedisLocker",
|
|
12
|
+
"extends": [
|
|
13
|
+
"css:dist/util/locking/RedisLocker.jsonld#RedisLocker"
|
|
14
|
+
],
|
|
15
|
+
"comment": "扩展 CSS RedisLocker,支持 redis:// 和 rediss:// URL 格式。 CSS 原生 RedisLocker.createRedisClient 是 private 的,无法 override。 这里在构造函数中检测 URL 格式,如果是 URL 则用 ioredis 直接创建连接, 替换掉父类构造函数中创建的(会报错的)连接。",
|
|
16
|
+
"parameters": [
|
|
17
|
+
{
|
|
18
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_redisClient",
|
|
19
|
+
"range": {
|
|
20
|
+
"@type": "ParameterRangeUnion",
|
|
21
|
+
"parameterRangeElements": [
|
|
22
|
+
"xsd:string",
|
|
23
|
+
{
|
|
24
|
+
"@type": "ParameterRangeUndefined"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_attemptSettings_retryCount",
|
|
31
|
+
"range": {
|
|
32
|
+
"@type": "ParameterRangeUnion",
|
|
33
|
+
"parameterRangeElements": [
|
|
34
|
+
"xsd:number",
|
|
35
|
+
{
|
|
36
|
+
"@type": "ParameterRangeUndefined"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_attemptSettings_retryDelay",
|
|
43
|
+
"range": {
|
|
44
|
+
"@type": "ParameterRangeUnion",
|
|
45
|
+
"parameterRangeElements": [
|
|
46
|
+
"xsd:number",
|
|
47
|
+
{
|
|
48
|
+
"@type": "ParameterRangeUndefined"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_attemptSettings_retryJitter",
|
|
55
|
+
"range": {
|
|
56
|
+
"@type": "ParameterRangeUnion",
|
|
57
|
+
"parameterRangeElements": [
|
|
58
|
+
"xsd:number",
|
|
59
|
+
{
|
|
60
|
+
"@type": "ParameterRangeUndefined"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_namespacePrefix",
|
|
67
|
+
"range": {
|
|
68
|
+
"@type": "ParameterRangeUnion",
|
|
69
|
+
"parameterRangeElements": [
|
|
70
|
+
"xsd:string",
|
|
71
|
+
{
|
|
72
|
+
"@type": "ParameterRangeUndefined"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"memberFields": [
|
|
79
|
+
{
|
|
80
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker__member_constructor",
|
|
81
|
+
"memberFieldName": "constructor"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"constructorArguments": [
|
|
85
|
+
{
|
|
86
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options__constructorArgument",
|
|
87
|
+
"fields": [
|
|
88
|
+
{
|
|
89
|
+
"keyRaw": "redisClient",
|
|
90
|
+
"value": {
|
|
91
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_redisClient"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"keyRaw": "attemptSettings_retryCount",
|
|
96
|
+
"value": {
|
|
97
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_attemptSettings_retryCount"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"keyRaw": "attemptSettings_retryDelay",
|
|
102
|
+
"value": {
|
|
103
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_attemptSettings_retryDelay"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"keyRaw": "attemptSettings_retryJitter",
|
|
108
|
+
"value": {
|
|
109
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_attemptSettings_retryJitter"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"keyRaw": "namespacePrefix",
|
|
114
|
+
"value": {
|
|
115
|
+
"@id": "undefineds:dist/storage/locking/UrlAwareRedisLocker.jsonld#UrlAwareRedisLocker_options_namespacePrefix"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
@@ -6,23 +6,22 @@ export interface AccountUsageRecord {
|
|
|
6
6
|
egressBytes: number;
|
|
7
7
|
storageLimitBytes?: number | null;
|
|
8
8
|
bandwidthLimitBps?: number | null;
|
|
9
|
+
computeSeconds: number;
|
|
10
|
+
tokensUsed: number;
|
|
11
|
+
computeLimitSeconds?: number | null;
|
|
12
|
+
tokenLimitMonthly?: number | null;
|
|
13
|
+
periodStart?: number | null;
|
|
9
14
|
}
|
|
10
15
|
export interface PodUsageRecord extends AccountUsageRecord {
|
|
11
16
|
podId: string;
|
|
12
17
|
}
|
|
13
18
|
/**
|
|
14
19
|
* Repository for tracking pod and account usage metrics.
|
|
15
|
-
*
|
|
16
|
-
* For local/dev modes, usage tracking should be disabled.
|
|
17
|
-
*
|
|
18
|
-
* TODO: Make UsageRepository database-agnostic to support SQLite in local mode.
|
|
19
|
-
* Required changes:
|
|
20
|
-
* - Replace `sql\`now()\`` with cross-database compatible timestamp (e.g., new Date())
|
|
21
|
-
* - Use Drizzle's database-agnostic transaction API or raw SQL compatible with both
|
|
22
|
-
* - Test with both SQLite and PostgreSQL backends
|
|
20
|
+
* Supports both PostgreSQL and SQLite through unified schema abstraction.
|
|
23
21
|
*/
|
|
24
22
|
export declare class UsageRepository {
|
|
25
23
|
private readonly db;
|
|
24
|
+
private readonly schema;
|
|
26
25
|
constructor(db: IdentityDatabase);
|
|
27
26
|
incrementUsage(accountId: string, podId: string, storageDelta: number, ingressDelta: number, egressDelta: number): Promise<void>;
|
|
28
27
|
incrementBandwidth(accountId: string, podId: string, ingressDelta: number, egressDelta: number): Promise<void>;
|
|
@@ -34,13 +33,47 @@ export declare class UsageRepository {
|
|
|
34
33
|
setPodStorageLimit(podId: string, accountId: string, limit: number | null): Promise<void>;
|
|
35
34
|
setAccountBandwidthLimit(accountId: string, limit: number | null): Promise<void>;
|
|
36
35
|
setPodBandwidthLimit(podId: string, accountId: string, limit: number | null): Promise<void>;
|
|
36
|
+
setAccountComputeLimit(accountId: string, limit: number | null): Promise<void>;
|
|
37
|
+
setAccountTokenLimit(accountId: string, limit: number | null): Promise<void>;
|
|
38
|
+
setPodComputeLimit(podId: string, accountId: string, limit: number | null): Promise<void>;
|
|
39
|
+
setPodTokenLimit(podId: string, accountId: string, limit: number | null): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Increment token usage for an account and pod.
|
|
42
|
+
*/
|
|
43
|
+
incrementTokenUsage(accountId: string, podId: string, tokensDelta: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Increment compute usage for an account and pod.
|
|
46
|
+
*/
|
|
47
|
+
incrementComputeUsage(accountId: string, podId: string, secondsDelta: number): Promise<void>;
|
|
48
|
+
private incrementAccountTokensWith;
|
|
49
|
+
private incrementPodTokensWith;
|
|
50
|
+
private incrementAccountComputeWith;
|
|
51
|
+
private incrementPodComputeWith;
|
|
37
52
|
private incrementAccountUsageWith;
|
|
38
53
|
private incrementPodUsageWith;
|
|
39
54
|
private upsertAccountUsage;
|
|
40
55
|
private upsertPodUsage;
|
|
56
|
+
/**
|
|
57
|
+
* Generic account limit setter for compute/token limits.
|
|
58
|
+
*/
|
|
59
|
+
private upsertAccountLimit;
|
|
60
|
+
/**
|
|
61
|
+
* Generic pod limit setter for compute/token limits.
|
|
62
|
+
*/
|
|
63
|
+
private upsertPodLimit;
|
|
41
64
|
private getPodUsageWith;
|
|
42
65
|
private normalizeDelta;
|
|
43
66
|
private normalizeValue;
|
|
44
67
|
private coerceNumber;
|
|
45
68
|
private coerceNullable;
|
|
69
|
+
/**
|
|
70
|
+
* Coerce timestamp value to Unix timestamp (seconds).
|
|
71
|
+
* Handles Date objects (from PG) and numbers (from SQLite).
|
|
72
|
+
*/
|
|
73
|
+
private coerceTimestamp;
|
|
74
|
+
/**
|
|
75
|
+
* Get the current timestamp in the format expected by the database.
|
|
76
|
+
* PG expects Date objects, SQLite expects Unix timestamps (seconds).
|
|
77
|
+
*/
|
|
78
|
+
private now;
|
|
46
79
|
}
|