Skip to content

Commit e5b8b1d

Browse files
Integrated Resource view from ODF spec.
`ResourceIdentity` concept renamed to `ResourceHandle`.
1 parent e039079 commit e5b8b1d

58 files changed

Lines changed: 896 additions & 940 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/internal/resources-framework.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ long-term goal. This page documents what exists now.
127127
| **Descriptor** | Schema (`TypeUri`) + selector name/aliases identifying a type for routing/presentation; domain type `ResourceTypeDescriptor`, carried in `dill` as `ResourceDispatcherMeta`. |
128128
| **Manifest** | The user-authored wire document (`$schema`/`headers`/`spec`) in YAML or JSON. |
129129
| **Spec** | The desired-state portion authored by the user; stored as `serde_json::Value`. |
130-
| **Status** | Server-owned observed state (`ResourceStatus`: `phase`, optional `observedGeneration`/`reconciledAt`/`conditions`). `conditions` is a `TypeRef → JSON` map. `generation` lives in **headers**, not status. |
130+
| **Status** | Server-owned observed state (`ResourceStatus`: `phase`, optional `observedGeneration`/`reconciledAt`/`conditions`). `conditions` is a `TypeRef → JSON` map. `generation` lives in **headers**, not status. On a `Resource` (domain/GraphQL), `status` is always present — a resource with no reconciliation yet gets a synthesized `Pending` status with no conditions. The `Option` lives only in the persisted `ResourceSnapshot` row (`None` before the first write completes). |
131131
| **Snapshot** | The persisted materialized form of a resource (`ResourceSnapshot`). |
132132
| **Phase** | Lifecycle stage: `Pending`, `Reconciling`, `Ready`, `Failed` (ODF RFC-018 `ResourcePhase`; see [§13 state machine](#lifecycle-state-machine)). |
133133
| **Condition** | A status signal keyed by a condition schema URI. Built-ins: `Accepted`, `Ready`, `Reconciling`; each value has `status`, `reason`, optional `message`, `lastTransitionTime`. |
@@ -418,6 +418,17 @@ pub struct ResourceStatus { // ODF-generated; entirely server-o
418418
> for free. Postgres/SQLite repos round-trip labels/annotations through the
419419
> `resource_labels_{from,to}_json` helpers; the Cynic remote client binds its own scalar newtypes.
420420
> This is a deliberate per-field cost of reusing the codegen shape, not a bug.
421+
>
422+
> The whole-resource envelope follows the same convention: domain `Resource`
423+
> ([`values/resource.rs`](/src/domain/resources/domain/src/values/resource.rs)) is a `pub type` alias of
424+
> `odf::metadata::resource::Resource<serde_json::Value>`, and the GraphQL `Resource` re-exports the
425+
> matching generated `SimpleObject`. Both live in `values/`, not `views/``views/` is reserved for
426+
> query-shaped results (`ResourceSummaryView`, list/apply-manifest outcomes), whereas `Resource` is the
427+
> canonical per-instance DTO. Its identity/lookup counterpart, domain `ResourceHandle`
428+
> ([`values/resource_handle.rs`](/src/domain/resources/domain/src/values/resource_handle.rs)`schema` +
429+
> `canonicalSelector` + `id` + `name`), has no ODF codegen equivalent and stays hand-rolled, but is
430+
> named and placed the same way. The GraphQL-facing type is also `ResourceHandle` (was
431+
> `ResourceIdentity`).
421432
422433
The behaviorally-significant consequences of adopting these shapes:
423434

@@ -684,15 +695,15 @@ pub trait ResourceFacade: Send + Sync {
684695
async fn list_supported_resource_types(&self) -> Result<Vec<ResourceTypeDescriptor>, ...>;
685696
async fn summary(&self, request: ResourcesSummaryRequest) -> Result<ResourcesSummary, ...>;
686697

687-
async fn get(&self, selector: ResourceSelector, spec_view_mode: SpecViewMode) -> Result<ResourceView, ...>;
698+
async fn get(&self, selector: ResourceSelector, spec_view_mode: SpecViewMode) -> Result<Resource, ...>;
688699
async fn get_many(&self, selector: ResourceBatchSelector, spec_view_mode: SpecViewMode)
689-
-> Result<BatchResourceResponse<ResourceView, ResourceLookupProblem>, ...>;
690-
async fn get_identity(&self, selector: ResourceSelector) -> Result<ResourceIdentityView, ...>;
700+
-> Result<BatchResourceResponse<Resource, ResourceLookupProblem>, ...>;
701+
async fn get_handle(&self, selector: ResourceSelector) -> Result<ResourceHandle, ...>;
691702
async fn render_manifest(&self, selector, format: ResourceManifestFormat, spec_view_mode) -> ...;
692703

693704
async fn list(&self, request: ListResourcesRequest) -> Result<Vec<ResourceSummaryView>, ...>;
694-
async fn list_identities(&self, request: ListResourceIdentitiesRequest) -> ...;
695-
async fn search_identities(&self, request: SearchResourceIdentitiesRequest) -> ...;
705+
async fn list_handles(&self, request: ListResourceHandlesRequest) -> ...;
706+
async fn search_handles(&self, request: SearchResourceHandlesRequest) -> ...;
696707
async fn list_all(&self, request: ListAllResourcesRequest) -> ...;
697708

698709
async fn plan_apply_manifest(&self, request: ApplyManifestRequest) -> Result<ApplyManifestPlanningDecision, ...>;
@@ -740,8 +751,8 @@ and [`adapter/graphql/src/mutations/resources_mut/`](/src/adapter/graphql/src/mu
740751
Every resolver delegates to `ResourceFacade`.
741752

742753
**Queries (`Resources`):** `supported_resource_types`, `summary`, `resource` / `resources`,
743-
`resource_identity` / `resource_identities`, `list_by_resource_type` /
744-
`list_identities_by_resource_type`, `search_identities`, `list_all` / `list_all_identities`,
754+
`resource_handle` / `resource_handles`, `list_by_resource_type` /
755+
`list_handles_by_resource_type`, `search_handles`, `list_all` / `list_all_handles`,
745756
`render_manifest` / `render_manifests`. The `revealed: bool` argument maps to `SpecViewMode`.
746757

747758
**Mutations (`ResourcesMut`):** `apply_manifest(manifest, format, dry_run?)`, `delete(selector)`,

resources/schema.gql

Lines changed: 71 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -577,16 +577,16 @@ Base64-encoded binary data (url-safe, no padding)
577577
"""
578578
scalar Base64Usnp
579579

580-
union BatchResourceIdentitiesOutcome = BatchResourceIdentitiesResult | ResourceUnsupportedSelectorProblem | ResourceBadAccountProblem
581-
582-
type BatchResourceIdentitiesResult {
583-
identities: [BatchResourceIdentitySuccess!]!
584-
problems: [BatchResourceProblem!]!
580+
type BatchResourceHandleSuccess {
581+
requestIndex: Int!
582+
handle: ResourceHandle!
585583
}
586584

587-
type BatchResourceIdentitySuccess {
588-
requestIndex: Int!
589-
identity: ResourceIdentity!
585+
union BatchResourceHandlesOutcome = BatchResourceHandlesResult | ResourceUnsupportedSelectorProblem | ResourceBadAccountProblem
586+
587+
type BatchResourceHandlesResult {
588+
handles: [BatchResourceHandleSuccess!]!
589+
problems: [BatchResourceProblem!]!
590590
}
591591

592592
type BatchResourceManifestSuccess {
@@ -3860,11 +3860,30 @@ type RequestHeader {
38603860
value: String!
38613861
}
38623862

3863+
"""
3864+
Top-level container for canonical representation of a resource that
3865+
specifies the type and version of the resource, carries identity, ownership,
3866+
and status information.
3867+
3868+
Schema: https://opendatafabric.org/schemas/resource/v1alpha1/Resource
3869+
"""
38633870
type Resource {
3871+
"""
3872+
Identifies the controlling entity, a bounded context that this resource belongs to, and the version. Url should follow the pattern `{base-url}/{context}/{version}/{name}.json` e.g. `https://opendatafabric.org/schemas/dataset/v1/Dataset.json`.
3873+
"""
38643874
schema: TypeUri!
3875+
"""
3876+
Container for identity and ownership information of a resource.
3877+
"""
38653878
headers: ResourceHeaders!
3879+
"""
3880+
Specifies the desired state of a resource.
3881+
"""
38663882
spec: JSON!
3867-
status: ResourceStatus
3883+
"""
3884+
Resource lifecycle and reconciliation information.
3885+
"""
3886+
status: ResourceStatus!
38683887
}
38693888

38703889
input ResourceAccountSelectorInput @oneOf {
@@ -3993,10 +4012,41 @@ type ResourceEdge {
39934012
node: ResourceSummary!
39944013
}
39954014

3996-
union ResourceGetIdentityOutcome = ResourceIdentity | ResourceSelectorProblemResult
4015+
union ResourceGetHandleOutcome = ResourceHandle | ResourceSelectorProblemResult
39974016

39984017
union ResourceGetOutcome = Resource | ResourceSelectorProblemResult
39994018

4019+
type ResourceHandle {
4020+
id: ResourceID!
4021+
schema: TypeUri!
4022+
canonicalSelector: ResourceSelectorName!
4023+
name: ResourceName!
4024+
}
4025+
4026+
type ResourceHandleConnection {
4027+
"""
4028+
A shorthand for `edges { node { ... } }`
4029+
"""
4030+
nodes: [ResourceHandle!]!
4031+
"""
4032+
Approximate number of total nodes
4033+
"""
4034+
totalCount: Int!
4035+
"""
4036+
Page information
4037+
"""
4038+
pageInfo: PageBasedInfo!
4039+
edges: [ResourceHandleEdge!]!
4040+
}
4041+
4042+
type ResourceHandleEdge {
4043+
node: ResourceHandle!
4044+
}
4045+
4046+
union ResourceHandleListAllOutcome = ResourceHandleConnection | ResourceBadAccountProblem
4047+
4048+
union ResourceHandleListOutcome = ResourceHandleConnection | ResourceUnsupportedSelectorProblem | ResourceBadAccountProblem | ResourceInvalidSearchQueryProblem
4049+
40004050
enum ResourceHeaderValidationProblemCode {
40014051
EMPTY_NAME
40024052
NAME_TOO_LONG
@@ -4071,37 +4121,6 @@ type ResourceIDNotFoundProblem {
40714121
message: String!
40724122
}
40734123

4074-
type ResourceIdentity {
4075-
id: ResourceID!
4076-
schema: TypeUri!
4077-
canonicalSelector: ResourceSelectorName!
4078-
name: ResourceName!
4079-
}
4080-
4081-
type ResourceIdentityConnection {
4082-
"""
4083-
A shorthand for `edges { node { ... } }`
4084-
"""
4085-
nodes: [ResourceIdentity!]!
4086-
"""
4087-
Approximate number of total nodes
4088-
"""
4089-
totalCount: Int!
4090-
"""
4091-
Page information
4092-
"""
4093-
pageInfo: PageBasedInfo!
4094-
edges: [ResourceIdentityEdge!]!
4095-
}
4096-
4097-
type ResourceIdentityEdge {
4098-
node: ResourceIdentity!
4099-
}
4100-
4101-
union ResourceIdentityListAllOutcome = ResourceIdentityConnection | ResourceBadAccountProblem
4102-
4103-
union ResourceIdentityListOutcome = ResourceIdentityConnection | ResourceUnsupportedSelectorProblem | ResourceBadAccountProblem | ResourceInvalidSearchQueryProblem
4104-
41054124
"""
41064125
A header field value (e.g. name, label key) failed validation.
41074126
"""
@@ -4327,33 +4346,33 @@ type Resources {
43274346
"""
43284347
resources(selector: ResourceBatchSelectorInput!, revealed: Boolean! = false): BatchResourcesOutcome!
43294348
"""
4330-
Returns resource identity by selector, if found
4349+
Returns resource handle by selector, if found
43314350
"""
4332-
resourceIdentity(selector: ResourceSelectorInput!): ResourceGetIdentityOutcome!
4351+
resourceHandle(selector: ResourceSelectorInput!): ResourceGetHandleOutcome!
43334352
"""
4334-
Returns resource identities by selectors
4353+
Returns resource handles by selectors
43354354
"""
4336-
resourceIdentities(selector: ResourceBatchSelectorInput!): BatchResourceIdentitiesOutcome!
4355+
resourceHandles(selector: ResourceBatchSelectorInput!): BatchResourceHandlesOutcome!
43374356
"""
43384357
Returns resources of the specified resource type
43394358
"""
43404359
listByResourceType(resourceType: ResourceTypeSelectorInput!, account: ResourceAccountSelectorInput, page: Int, perPage: Int): ResourceListOutcome!
43414360
"""
4342-
Returns resource identities of the specified resource type
4361+
Returns resource handles of the specified resource type
43434362
"""
4344-
listIdentitiesByResourceType(resourceType: ResourceTypeSelectorInput!, account: ResourceAccountSelectorInput, page: Int, perPage: Int): ResourceIdentityListOutcome!
4363+
listHandlesByResourceType(resourceType: ResourceTypeSelectorInput!, account: ResourceAccountSelectorInput, page: Int, perPage: Int): ResourceHandleListOutcome!
43454364
"""
4346-
Searches resource identities across the specified exact resource types
4365+
Searches resource handles across the specified exact resource types
43474366
"""
4348-
searchIdentities(query: SearchResourceIdentitiesInput!, page: Int, perPage: Int): ResourceIdentityListOutcome!
4367+
searchHandles(query: SearchResourceHandlesInput!, page: Int, perPage: Int): ResourceHandleListOutcome!
43494368
"""
43504369
Returns resources across all resource types
43514370
"""
43524371
listAll(account: ResourceAccountSelectorInput, page: Int, perPage: Int): ResourceListAllOutcome!
43534372
"""
4354-
Returns resource identities across all resource types
4373+
Returns resource handles across all resource types
43554374
"""
4356-
listAllIdentities(account: ResourceAccountSelectorInput, page: Int, perPage: Int): ResourceIdentityListAllOutcome!
4375+
listAllHandles(account: ResourceAccountSelectorInput, page: Int, perPage: Int): ResourceHandleListAllOutcome!
43574376
"""
43584377
Renders a canonical manifest representation from a stored resource
43594378
"""
@@ -4450,7 +4469,7 @@ enum SearchEntityName {
44504469
ACCOUNTS
44514470
}
44524471

4453-
input SearchResourceIdentitiesInput {
4472+
input SearchResourceHandlesInput {
44544473
resourceTypes: [ResourceTypeSelectorInput!]!
44554474
names: [ResourceName!]
44564475
namePattern: String

src/adapter/graphql/src/queries/datasets/dataset_configuration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a> DatasetConfiguration<'a> {
6262

6363
let ids: Vec<_> = bindings.iter().map(|b| b.resource_id).collect();
6464
let identities = generic_resource_query_svc
65-
.find_resource_identities_by_ids(current_account_id, &ids)
65+
.find_resource_handles_by_ids(current_account_id, &ids)
6666
.await
6767
.int_err()?;
6868

@@ -114,7 +114,7 @@ impl<'a> DatasetConfiguration<'a> {
114114

115115
let ids: Vec<_> = bindings.iter().map(|b| b.resource_id).collect();
116116
let identities = generic_resource_query_svc
117-
.find_resource_identities_by_ids(current_account_id, &ids)
117+
.find_resource_handles_by_ids(current_account_id, &ids)
118118
.await
119119
.int_err()?;
120120

0 commit comments

Comments
 (0)